Preserve scalar negation types when folding FMA operands - #134522
Merged
tannergooding merged 1 commit intoSep 24, 2026
Merged
Conversation
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
Cross-architecture JIT lowering changes warrant final human review.
Review effort: Lite
Findings: None
What changed in this PR
Fixes incorrect FMA negation folding across scalar type reinterprets on ARM64 and xarch.
Changes:
- Require matching scalar and FMA element types before negation folding.
- Add regressions for mismatched, same-type, and signed-zero cases.
| File | Description |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_134053.cs |
Adds focused regression tests and controls. |
src/coreclr/jit/lowerxarch.cpp |
Restricts scalar negation folding by type. |
src/coreclr/jit/lowerarmarch.cpp |
Applies the matching-type safeguard on ARM64. |
EgorBo
approved these changes
Sep 24, 2026
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.
Require the scalar
GT_NEGtype to match the FMA element type before folding it into a negated FMA variant on ARM64 and xarch.Vector bit reinterprets can expose integer negation or a different floating-point width to these folds. Integer negation is not a floating-point sign change, and double negation does not change the sign of a float in the low 32 bits. Preserve those operations while retaining same-type fusion, without changing operand evaluation order.
Add focused regressions for both mismatch classes and the analogous xarch path, plus same-type finite and signed-zero controls.
Validation:
JitStress=2.negor doublefnegbeforefmaddfor the repros. Same-type control disassembly is unchanged. Native ARM64 execution was unavailable.Resolves #134053
Note
This PR description was drafted with GitHub Copilot.