-
Notifications
You must be signed in to change notification settings - Fork 5k
Vector128.WithElement codegen regression in .NET 9.0 #115348
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
Vector128.WithElement codegen regression in .NET 9.0 #115348
Conversation
…trinsicAsUserCall
…with ins_Move_Extend
…s in RewriteHWIntrinsicAsUserCall
There was a problem hiding this 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 fixes the handling of NI_Vector*_WithElement intrinsics so that user calls are removed and the behavior is aligned with GetElement (spill, set value, then reload).
- Removed the NI_Vector*_WithElement user call handling in Rationalizer.
- Updated lowering, codegen, and tree construction functions to correctly manage non-constant index cases by using spill temporary variables and performing range checks.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/coreclr/jit/rationalize.cpp | Removed the special handling for NI_Vector*_WithElement to mirror GetElement behavior. |
src/coreclr/jit/lowerxarch.cpp | Added special handling for non-constant op2 by obtaining a SIMD temp var and deferring containment. |
src/coreclr/jit/hwintrinsicxarch.cpp | Removed the early return branch for non-constant index handling in favor of later processing. |
src/coreclr/jit/hwintrinsiccodegenxarch.cpp | Added a branch for non-constant op2 that stores the vector, updates the element, and reloads it. |
src/coreclr/jit/gentree.cpp | Updated node creation to perform a range check for non-constant op2 values before constructing the intrinsic node. |
@@ -5653,7 +5653,14 @@ GenTree* Lowering::LowerHWIntrinsicWithElement(GenTreeHWIntrinsic* node) | |||
GenTree* op2 = node->Op(2); | |||
GenTree* op3 = node->Op(3); | |||
|
|||
assert(op2->OperIsConst()); | |||
if (!op2->OperIsConst()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding an inline comment explaining why a SIMD initialization temp variable is obtained when op2 is not a constant for improved clarity.
Copilot uses AI. Check for mistakes.
unsigned offs = compiler->lvaFrameAddress(simdInitTempVarNum, &isEBPbased); | ||
|
||
#if !FEATURE_FIXED_OUT_ARGS | ||
if (!isEBPbased) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider clarifying inline how the offset 'offs' is adjusted for non-EBP-based stacks to ensure the correct offset calculation across platforms.
Copilot uses AI. Check for mistakes.
@@ -27959,6 +27953,20 @@ GenTree* Compiler::gtNewSimdWithElementNode( | |||
#error Unsupported platform | |||
#endif // !TARGET_XARCH && !TARGET_ARM64 | |||
|
|||
int immUpperBound = getSIMDVectorLength(simdSize, simdBaseType) - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an explanatory comment regarding the rationale for using 'getSIMDVectorLength(simdSize, simdBaseType) - 1' as the upper bound to aid future maintainability.
Copilot uses AI. Check for mistakes.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
@dotnet-policy-service agree company="Intel" |
@dotnet/intel |
…re to load instruction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. CC. @dotnet/jit-contrib, @BruceForstall for secondary review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Looks like perhaps jit-format failed to run? I am getting formatting errors in this file in my PR
|
Created #115416 to try fix the issue. |
Description
Fixes #108197.
Removes the handling of
NI_Vector*_WithElement
as a user call and mirrors the behavior ofGetElement
to emit the spill, set the value and then reload the vector.