Skip to content

Commit 51fcdf7

Browse files
Encode the previous instruction's source reg to match consecutive loads from the same stack location (#83886)
1 parent 18a0403 commit 51fcdf7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/coreclr/jit/emitarm64.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16369,7 +16369,7 @@ emitter::RegisterOrder emitter::IsOptimizableLdrStrWithPair(
1636916369
// instruction into a cheaper "mov" instruction.
1637016370
//
1637116371
// Examples: ldr w1, [x20, #0x10]
16372-
// ldr w2, [x20, #0x10] => mov w1, w2
16372+
// ldr w2, [x20, #0x10] => mov w2, w1
1637316373
//
1637416374
// Arguments:
1637516375
// ins - The instruction code
@@ -16398,7 +16398,7 @@ bool emitter::IsOptimizableLdrToMov(
1639816398
}
1639916399

1640016400
regNumber prevReg1 = emitLastIns->idReg1();
16401-
regNumber prevReg2 = emitLastIns->idReg2();
16401+
regNumber prevReg2 = encodingZRtoSP(emitLastIns->idReg2());
1640216402
insFormat lastInsFmt = emitLastIns->idInsFmt();
1640316403
emitAttr prevSize = emitLastIns->idOpSize();
1640416404
ssize_t prevImm = emitGetInsSC(emitLastIns);
@@ -16418,8 +16418,7 @@ bool emitter::IsOptimizableLdrToMov(
1641816418

1641916419
if (!isGeneralRegister(reg1) || !isGeneralRegister(prevReg1))
1642016420
{
16421-
// Either register 1 or previous register 1 is not a general register
16422-
// or the zero register, so we cannot optimise.
16421+
// We cannot optimise when register 1 or previous register 1 is a general register.
1642316422
return false;
1642416423
}
1642516424

0 commit comments

Comments
 (0)