Repository navigation
ARM64 reenable IsRedundantLdStr - #137952
Conversation
|
Azure Pipelines: Successfully started running 6 pipeline(s). 9 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 |
There was a problem hiding this comment.
🟡 Changes recommended
The optimization can eliminate a required ARM64 volatile read, reusing the stored value instead of allowing the load to observe another thread’s write.
2 open issues
What changed in this PR
This PR re-enables redundant load/store elimination in the ARM64 JIT emitter, addressing #137871 and reducing generated code size.
Changes:
- Moves the same-instruction check after redundant load/store detection.
- Requires matching garbage-collection metadata before eliminating an instruction.
- Allows sub-64-bit vector loads to qualify while preserving zero-extension checks for general-purpose registers.
| File | Description |
|---|---|
src/coreclr/jit/emitarm64.cpp |
Re-enables load/store elimination and adjusts register-size and GC-metadata guards. |
Review effort: Balanced
|
I didn't see anything worth noting beyond what copilot found. Ping me again when you've pushed more changes. |
There was a problem hiding this comment.
🟡 Changes recommended
The disassembly tests do not verify removal of nonvolatile ARM64 store/load pairs, including the newly permitted floating-point case, so they would miss a regression that disables the optimization.
1 open issue
2 resolved since last review
Review effort: Balanced
|
@AndyAyersMS should be ready for review. Addressed the copilot PR feedback. The volatile-issue it pointed out was also an issue with one of the other peeps in this routine. Also accepted the SpToZR change, that didn't get extra diffs though. |



Peep to look for redundant
ldr+str/str+ldrpairs won't fire currently, because its blocked by a check that previous instr and current instr are the same.Fix is to move the
emitLastIns->idIns() != inscheck later in the function. Also needed to add a check to not perform removal if the pair has mismatching gc info. This was needed for some unsafe code, though I wasn't able to build a repro that required this to pass.Sample diff:
ldapur x0, [x0, #-0x10] ; byrRegs +[x0] str x0, [fp, #0x18] // [V05 tmp4] - ldr x0, [fp, #0x18] // [V05 tmp4] and x0, x0, #-2 ; byrRegs -[x0] str xzr, [fp, #0x18] // [V05 tmp4] - ;; size=48 bbWeight=1 PerfScore 16.50 + ;; size=44 bbWeight=1 PerfScore 14.50Diffs look good. 127,948 bytes saved across 1,388,596 FullOpts contexts. No regressions. There's some +0 diffs like
ldpchanging toldr. This is due to a now-removed ldr now stopping a "combine-ldr-into-ldp" peep from firing. This won't regress performance.fixes #137871