Skip to content

Check containment for op3 for ternary instruction #116229

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

kunalspathak
Copy link
Member

Fixes: #111835

@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 Jun 2, 2025
Copy link
Contributor

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

@kunalspathak kunalspathak marked this pull request as ready for review June 3, 2025 05:18
@Copilot Copilot AI review requested due to automatic review settings June 3, 2025 05:18
@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib @saucecontrol

Copy link
Contributor

@Copilot 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 updates the containment logic for op3 in a ternary instruction to correctly account for memory load operations on hardware intrinsics, addressing issue #111835.

  • Added a new conditional branch to check if op3 is a contained GT_HWINTRINSIC memory load and use the proper address use builder.
  • Retains the previous behavior for RMW and non-contained cases using BuildDelayFreeUses and BuildOperandUses respectively.

Comment on lines +2968 to +2970
if (op3->OperIs(GT_HWINTRINSIC) && op3->AsHWIntrinsic()->OperIsMemoryLoad() && op3->isContained())
{
srcCount += BuildAddrUses(op3->AsHWIntrinsic()->Op(1), op3RegCandidates);
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider caching the result of op3->AsHWIntrinsic() in a local variable to improve readability and potentially reduce redundant method calls. For example, store the cast result in a variable and then reuse it within the conditional block.

Suggested change
if (op3->OperIs(GT_HWINTRINSIC) && op3->AsHWIntrinsic()->OperIsMemoryLoad() && op3->isContained())
{
srcCount += BuildAddrUses(op3->AsHWIntrinsic()->Op(1), op3RegCandidates);
auto op3HWIntrinsic = op3->AsHWIntrinsic();
if (op3->OperIs(GT_HWINTRINSIC) && op3HWIntrinsic->OperIsMemoryLoad() && op3->isContained())
{
srcCount += BuildAddrUses(op3HWIntrinsic->Op(1), op3RegCandidates);

Copilot uses AI. Check for mistakes.

@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib ping

@kunalspathak kunalspathak merged commit a16df1d into dotnet:main Jun 4, 2025
111 of 114 checks passed
@kunalspathak kunalspathak deleted the issue_111835 branch June 4, 2025 16:11
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assertion failed '(consume == 0) || (ComputeAvailableSrcCount(tree) == consume)'
2 participants