While working on #148217, I found that the _fixup_constants optimizer in Tools/jit/_optimizers.py fails to convert adrp+ldr to movz when the two instructions are split by a label.
Example: _LOAD_FAST_r01
// Before (8 instructions):
adrp x8, __JIT_OPARG_16@GOTPAGE
ldr x8, [x8, __JIT_OPARG_16@GOTPAGEOFF]
add x8, x21, w8, uxth #3
ldr x24, [x8, #0x50]
tbnz w24, #0x0, ...
ldr w8, [x24]
add w8, w8, #0x1
str w8, [x24]
// After (7 instructions):
movz x8, #0x0
add x8, x21, w8, uxth #3
ldr x24, [x8, #0x50]
tbnz w24, #0x0, ...
ldr w8, [x24]
add w8, w8, #0x1
str w8, [x24]
Example: _LOAD_FAST_BORROW_r01
// Before (5 instructions):
adrp x8, __JIT_OPARG_16@GOTPAGE
ldr x8, [x8, __JIT_OPARG_16@GOTPAGEOFF]
add x8, x21, w8, uxth #3
ldr x8, [x8, #0x50]
orr x24, x8, #0x1
// After (4 instructions):
movz x8, #0x0
add x8, x21, w8, uxth #3
ldr x8, [x8, #0x50]
orr x24, x8, #0x1
Linked PRs
While working on #148217, I found that the
_fixup_constantsoptimizer inTools/jit/_optimizers.pyfails to convertadrp+ldrtomovzwhen the two instructions are split by a label.Example:
_LOAD_FAST_r01Example:
_LOAD_FAST_BORROW_r01Linked PRs