Fix SIMD complement and scalar FMA folding - #133542
Open
tannergooding wants to merge 2 commits into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It changes CoreCLR JIT optimization behavior for SIMD intrinsics, where subtle codegen/semantics regressions are high-impact and should get final human validation across relevant xarch paths.
Review tier: Lite
Findings: None
What changed in this PR
This PR adjusts CoreCLR JIT optimization/folding around SIMD bitwise-complement patterns to preserve scalar-intrinsic upper-lane semantics, and fixes predicate folding for packed AVX comparisons so the complement is not dropped. It adds focused JIT regression tests to lock in the corrected behavior.
Changes:
- Prevent
~(scalar-compare)from being folded via comparison reversal (since scalar compares copy upper lanes from the first operand). - When folding
~Avx.Compare(..., imm8), invert the immediate predicate (and update VN) instead of dropping the NOT without changing the mode. - Avoid folding vector-negation from the first operand of scalar FMA (since scalar FMA copies upper lanes from operand 1).
| File | Description |
|---|---|
| src/coreclr/jit/morph.cpp | Fixes NOT-folding for SIMD compares: blocks scalar-compare reversal and correctly inverts AVX/AVX512 compare immediates. |
| src/coreclr/jit/lowerxarch.cpp | Prevents scalar FMA folding from losing upper-lane negation on operand 1. |
| src/tests/JIT/Regression/Regression_ro_2.csproj | Adds the new regression test sources to the merged JIT regression project. |
| src/tests/JIT/Regression/JitBlue/Runtime_133518/Runtime_133518.cs | Regression coverage for packed AVX/AVX512 compare complement folding with inverted predicates. |
| src/tests/JIT/Regression/JitBlue/Runtime_133521/Runtime_133521.cs | Regression coverage for scalar compare complement upper-lane preservation and scalar FMA operand-1 negation semantics. |
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.
Preserve upper lanes when folding scalar SIMD operations: reversing a scalar comparison cannot replace a full-vector complement, and folding a vector negation from scalar FMA's first operand changes its copied upper lanes.
Also use the inverted immediate predicate when folding packed AVX comparison complements. Includes focused regression coverage for both comparison paths and scalar FMA variants.
Fixes #133521
Fixes #133518
Fixes #133553
Note
This PR was prepared with GitHub Copilot.