- Notifications
You must be signed in to change notification settings - Fork5.2k
[RISC-V] Use srli instead of srai for 32-bit unsigned mulhi#122014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Tagging subscribers to this area:@JulieLeeMSFT,@jakobbotsch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull request overview
This PR improves the semantic correctness of the RISC-V 32-bit unsigned multiply-high implementation by replacing an arithmetic right shift (srai) with a logical right shift (srli). While both instructions produce the same functional result due to how the high bits are discarded,srli better represents the unsigned nature of the operation and aligns with established patterns elsewhere in the codebase.
- Replaced
INS_sraiwithINS_srliin the 32-bit unsigned mulhi code path - Aligned instruction choice with the semantic meaning of unsigned operations
- Maintained consistency with other zero-extend patterns in the file (e.g., lines 5851, 5866-5867)
The 32-bit unsigned mulhi implementation previously used an arithmetic right shift (
srai) to extract the high 32 bits from the widened 64-bit product. While this happens to produce correct results because the sign-extended high bits are discarded, the instruction does not semantically match the unsigned operation.Using
srlibetter reflects the intended semantics of an unsigned high-half multiply and avoids relying on sign-extension behavior.No functional behavior change is expected.
Part of#84834, cc @dotnet/samsung
@namu-lee