[arm64] Avoid sign-extending TYP_INT register moves#129864
Open
AndyAyersMS wants to merge 2 commits into
Open
Conversation
Revise ins_Move_Extend to emit mov instead of a sxtw for TYP_INT moves. Add an optional dstType arg to assert the move is valid and non-widening. Fixes dotnet#129052. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Member
Author
|
Impacts about 150K instructions across 62K methods in SPMI. @tannergooding PTAL |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts ARM64 JIT move/extend selection so that TYP_INT register-to-register moves no longer emit sxtw (sign-extend) and instead use mov, avoiding unnecessary work when the value remains int-typed. It also adds an optional dstType parameter to help assert move validity (non-widening) and introduces a JIT disasm-based regression test.
Changes:
- Update
ins_Move_Extend(ARM64) to returnINS_movforTYP_INTreg-reg moves instead ofINS_sxtw. - Thread an optional
dstTypethroughinst_Mov_Extend/ins_Move_Extendand add a debug assert to validate non-widening moves. - Add a new ARM64 disasm-check regression test under
InstructionCombining.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/jit/instr.cpp | ARM64 ins_Move_Extend now prefers mov for TYP_INT reg-reg moves; adds optional dstType assertion plumbing. |
| src/coreclr/jit/codegen.h | Updates declarations to include the new optional dstType parameter. |
| src/tests/JIT/opt/InstructionCombining/IntMoveNoSignExtend.cs | New disasm-check test validating no sxtw is emitted for int moves and that real int -> long widening still uses sxtw. |
| src/tests/JIT/opt/InstructionCombining/IntMoveNoSignExtend.csproj | New test project wiring with disasm checks and environment variable settings. |
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static int IntMove() | ||
| { | ||
| //ARM64-NOT: sxtw {{w[0-9]+}}, {{w[0-9]+}} |
Comment on lines
+2017
to
+2018
| // A TYP_INT value only needs its low 32 bits; mov Wd, Wn zero extends the rest. | ||
| ins = INS_mov; |
Broaden the int/long mov comment to mention the EA_4BYTE zero extension, and simplify the test's sxtw disasm check to a bare ARM64-NOT. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Revise ins_Move_Extend to emit mov instead of a sxtw for TYP_INT moves. Add an optional dstType arg to assert the move is valid and non-widening.
Fixes #129052.