Skip to content

Commit 0be7d59

Browse files
Arm64: Optimize pairs of "str wzr" to "str xzr" (#84350)
Optimise following patterns ``` stp wzr, wzr, [x2, #0x08] => str xzr, [x2, #0x08] ``` and ``` stp wzr, wzr, [x14, #0x20] str xzr, [x14, #0x18] => stp xzr, xzr, [x14, #0x18] ```
1 parent aca3fcc commit 0be7d59

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/coreclr/jit/emitarm64.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16220,6 +16220,16 @@ bool emitter::ReplaceLdrStrWithPairInstr(
1622016220
// Remove the last instruction written.
1622116221
emitRemoveLastInstruction();
1622216222

16223+
// Combine two 32 bit stores of value zero into one 64 bit store
16224+
if (ins == INS_str && reg1 == REG_ZR && oldReg1 == REG_ZR && size == EA_4BYTE)
16225+
{
16226+
16227+
// The first register is at the lower offset for the ascending order
16228+
ssize_t offset = (optimizationOrder == eRO_ascending ? oldImm : imm) * size;
16229+
emitIns_R_R_I(INS_str, EA_8BYTE, REG_ZR, reg2, offset, INS_OPTS_NONE);
16230+
return true;
16231+
}
16232+
1622316233
// Emit the new instruction. Make sure to scale the immediate value by the operand size.
1622416234
if (optimizationOrder == eRO_ascending)
1622516235
{

0 commit comments

Comments
 (0)