JIT: Preserve SIMD operand evaluation and ordering - #133776
Open
tannergooding wants to merge 3 commits into
Open
JIT: Preserve SIMD operand evaluation and ordering#133776tannergooding wants to merge 3 commits into
tannergooding wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Carry source evaluation order on two-operand nodes instead of relying on importer spills, and handle reversed stores during local morph. Retain spills where operand decomposition still requires stable values. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
Ended up going through and looking at all the SIMD related places that might have similar issues and ensuring they're consistent and correct. This looked to be all of them, but it ended up growing the PR compared to the absolute minimal fix. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Three unresolved moderate comments remain in gentree.cpp, requiring fixes and human review.
Review tier: Lite
Findings: None
What changed in this PR
This PR preserves SIMD operand evaluation order and observable effects during JIT folding and decomposition for issue #133718.
Changes:
- Adds observable-effect tracking and ordering-aware SIMD builders.
- Preserves evaluation order across shifts, element operations, stores, Min/Max folding, and platform-specific paths.
- Adds regression coverage for affected evaluation-order cases.
| File | Summary |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_133718.cs |
Adds SIMD evaluation-order regression tests. |
src/coreclr/jit/optimizer.cpp |
Uses observable-effect tracking during optimization. |
src/coreclr/jit/optimizebools.cpp |
Updates effect checks for boolean optimization. |
src/coreclr/jit/morph.cpp |
Preserves effects when folding operations. |
src/coreclr/jit/lclmorph.cpp |
Handles reversed evaluation order during local-store morphing. |
src/coreclr/jit/importercalls.cpp |
Preserves RISC-V Min/Max operand order. |
src/coreclr/jit/importer.cpp |
Updates inline argument effect tracking. |
src/coreclr/jit/ifconversion.cpp |
Uses observable effects during if-conversion. |
src/coreclr/jit/hwintrinsicxarch.cpp |
Updates xarch intrinsic effect handling. |
src/coreclr/jit/hwintrinsic.cpp |
Adjusts SIMD sequence, division, and store importing. |
src/coreclr/jit/gentree.h |
Defines observable-effect flags. |
src/coreclr/jit/gentree.cpp |
Implements ordering-aware SIMD folding and builders. Three moderate comments remain about materializing address-exposed operands before duplication. |
src/coreclr/jit/compiler.h |
Extends SIMD store-builder declarations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #133718.
Preserve observable evaluation when SIMD folding discards an operand, including constant-NaN Min/Max. Keep operand evaluation and validation in source order through shift emulation, GetElement/WithElement, scalar-left multiplication, sequences, and value-first stores.
Use
GTF_OBS_EFFECTto distinguish observable effects from unused ordinary reads. Carry binary evaluation order in the builders instead of relying on importer spills, including local-morph handling for reversed stores and unary local-store folding. Retain WASM, FMA, and decomposition spills where still required; avoid unnecessary captures for invariant single-lane results and direct int/uint division nodes. Also clone scalar Min/Max operands in source order on RISC-V.This does not change NaN payload-selection policy or address the separate XCHG/local-value-interference problem.
Validation
Vector128<int>.CreateSequencearray-load probe drops from 63 to 57 bytes and 16 to 14 instructions; direct integer-division and ordinary-store controls are unchanged. Seven pure Min/Max, Number, and finite controls have identical disassembly. These are codegen measurements, not throughput benchmarks.ARM64 was compiled but not executed. WASM and RISC-V were not built or executed; the ARM64 single-lane optimizations were not measured natively.
Note
This PR description was drafted with GitHub Copilot.