Skip to content

Conversation

@credo-quia-absurdum
Copy link
Contributor

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 srli better 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

Copilot AI review requested due to automatic review settings November 27, 2025 07:25
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 27, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Nov 27, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copilot finished reviewing on behalf of credo-quia-absurdum November 27, 2025 07:27
Copy link
Contributor

Copilot AI left a 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_srai with INS_srli in 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-riscv Related to the RISC-V architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants