Skip to content

[Wasm RyuJit] avoid reverse ops#124189

Merged
AndyAyersMS merged 2 commits intodotnet:mainfrom
AndyAyersMS:WasmNoReverseOps
Feb 10, 2026
Merged

[Wasm RyuJit] avoid reverse ops#124189
AndyAyersMS merged 2 commits intodotnet:mainfrom
AndyAyersMS:WasmNoReverseOps

Conversation

@AndyAyersMS
Copy link
Member

For Wasm we generally want operands evaluated in the normal order. So, suppress marking nodes with GT_REVERSE_OPS. On Wasm reversal is still possible for relops (where we can change the oper) and for commutative ops (where we can swap the operands).

We may want to enable reversal in other cases where there is a big imbalance in child tree complexity, but then we'll need to add changes to lower to spill the out of order tree to a temp to handle this.

For Wasm we generally want operands evaluated in the normal order.
So suppress creating nodes with GT_REVERSE_OPS. On Wasm reversal is still
possible for relops (where we can change the oper) and for commutative
ops (where we can swap the operands).

We may want to enable reversal in other cases where there is a big
imbalance in child tree complexity, but then we'll need to add changes to
lower to spill the out of order tree to a temp to handle this.
Copilot AI review requested due to automatic review settings February 9, 2026 17:48
@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 Feb 9, 2026
@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.

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 adjusts JIT tree evaluation-order heuristics for the WebAssembly target to prefer normal (non-reversed) operand evaluation order, avoiding use of GTF_REVERSE_OPS except where reversal can be expressed via operand swapping (commutative ops) or operator swapping (relops).

Changes:

  • Disable reversal for indirect stores on WASM by forcing allowReversal = false in SetIndirectStoreEvalOrder.
  • On WASM, suppress setting GTF_REVERSE_OPS in the “can’t commute” default swap path in both gtSetEvalOrder and gtSetEvalOrderMinOpts.

@AndyAyersMS
Copy link
Member Author

fyi @dotnet/jit-contrib

Fixes some "IR not in stack order" asserts that we hit after lowering a reversed STOREIND.

The remaining instances of the "IR not in stack order" assert mostly seem to come from call lowering now, as best I can tell.

Copy link
Contributor

@SingleAccretion SingleAccretion left a comment

Choose a reason for hiding this comment

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

You can also consider adding a condition into OperSupportsReverseOpEvalOrder.

@AndyAyersMS
Copy link
Member Author

You can also consider adding a condition into OperSupportsReverseOpEvalOrder.

Good idea.

@AndyAyersMS
Copy link
Member Author

Various errors, all unrelated as this change is currently untestable in CI.

One looks like #123912. Another is infra...

ModuleNotFoundError: No module named 'pkg_resources'

@AndyAyersMS
Copy link
Member Author

/ba-g unrelated errors

@AndyAyersMS
Copy link
Member Author

/ba-g retry

@AndyAyersMS AndyAyersMS merged commit 6c841af into dotnet:main Feb 10, 2026
115 of 123 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

4 participants