Repository navigation
JIT: skip lane bounds for constant ARM64 indices - #137583
AndyAyersMS wants to merge 2 commits into
Conversation
Fixes dotnet#135526. Co-authored-by: Copilot <[email protected]> Copilot-Session: dfb97b66-e90e-4673-a5ce-6fbdf442c56d
|
Azure Pipelines: Successfully started running 7 pipeline(s). 8 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
@dhartglass PTAL |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the ARM64 constant-index register-allocation change.
No open issues 🎉
What changed in this PR
This PR adjusts ARM64 JIT register allocation to skip lane-bound lookup for constant indexed-element operands, preserving scalar-wrapper elimination.
Changes:
- Returns early for constant indices, which need no jump-table register.
- Adds regression coverage for scalar-created operands with
Vector64<float>,Vector128<float>, andVector128<double>.
| File | Description |
|---|---|
| src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/Program.AdvSimd.cs | Adds constant-index multiplication regression tests using CreateScalarUnsafe. |
| src/coreclr/jit/lsraarm64.cpp | Skips indexed-element lane-bound lookup for contained constant indices. |
Review effort: Balanced
| if (intrin.category == HW_Category_SIMDByIndexedElement) | ||
| { | ||
| // A constant index needs no jump table, and lowering may have replaced its SIMD operand with a scalar. | ||
| if (intrinsicTree->Op(intrin.numOperands)->isContainedIntOrIImmed()) |
There was a problem hiding this comment.
My understanding of this bug is we have something like
AdvSimd.MultiplyBySelectedScalar(a, Vector64.CreateScalarUnsafe(x), index)
Lowering of CreateScalarUnsafe puts a scalar typed node into the IndexedElement position right?
This bail avoids the assert+weird index calculation only when index is constant. Or, is there some enforced invariant that we can't get a scalar operand here UNLESS we have a constant index?
There was a problem hiding this comment.
If the index is not constant then the intrinsic becomes a call to a managed fallback and CreateScalarUnsafe remains, and LSRA may need to allow for an internal register.
If the index is a constant CreateScalarUnsafe may get replaced by a scalar, depending on the scalar type and consumer; either way we don't care as no interal register is needed.
Co-authored-by: Copilot <[email protected]> Copilot-Session: dfb97b66-e90e-4673-a5ce-6fbdf442c56d
Skip the indexed-element lane-bound lookup in LSRA when the index is constant. It needs no jump-table register, and lowering may have replaced
CreateScalarUnsafewith a scalar operand. This matches codegen's existing constant-index handling and preserves scalar-wrapper elimination.Adds regression coverage for
Vector64<float>,Vector128<float>, andVector128<double>.Validated on macOS ARM64 (M4): Checked JIT build passed; all 5,381 optimized ARM intrinsic cases passed, including the new regression, which asserts on the unpatched JIT.
superpmi.py asmdiffsreplayed 446,262 contexts with zero assembly diffs or misses. JIT formatting passed.Resolves #135526
Note
This PR description and the changes were developed with GitHub Copilot.