Vector128.WithElement codegen regression in .NET 9.0#115348
Vector128.WithElement codegen regression in .NET 9.0#115348kunalspathak merged 10 commits intodotnet:mainfrom
Conversation
…trinsicAsUserCall
…with ins_Move_Extend
…s in RewriteHWIntrinsicAsUserCall
There was a problem hiding this comment.
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. |
| GenTree* op3 = node->Op(3); | ||
|
|
||
| assert(op2->OperIsConst()); | ||
| if (!op2->OperIsConst()) |
There was a problem hiding this comment.
Consider adding an inline comment explaining why a SIMD initialization temp variable is obtained when op2 is not a constant for improved clarity.
| unsigned offs = compiler->lvaFrameAddress(simdInitTempVarNum, &isEBPbased); | ||
|
|
||
| #if !FEATURE_FIXED_OUT_ARGS | ||
| if (!isEBPbased) |
There was a problem hiding this comment.
Consider clarifying inline how the offset 'offs' is adjusted for non-EBP-based stacks to ensure the correct offset calculation across platforms.
| #error Unsupported platform | ||
| #endif // !TARGET_XARCH && !TARGET_ARM64 | ||
|
|
||
| int immUpperBound = getSIMDVectorLength(simdSize, simdBaseType) - 1; |
There was a problem hiding this comment.
Add an explanatory comment regarding the rationale for using 'getSIMDVectorLength(simdSize, simdBaseType) - 1' as the upper bound to aid future maintainability.
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
@dotnet-policy-service agree company="Intel" |
|
@dotnet/intel |
…re to load instruction
tannergooding
left a comment
There was a problem hiding this comment.
LGTM. CC. @dotnet/jit-contrib, @BruceForstall for secondary review
|
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*_WithElementas a user call and mirrors the behavior ofGetElementto emit the spill, set the value and then reload the vector.