mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-10 19:47:40 +01:00

You can encode a shifted 12-bit immediate in an ADD instruction on ARM64. If the negated constant fits in this range, we can exploit this to avoid materializing the immediate. This approach saves an instruction if it does not need to be materialized in a register afterwards. Otherwise, we just materialize it later and the total number of instructions stays the same. Before: 0x52bff01a mov w26, #-0x800000 ; =-8388608 0x93407f1b sxtw x27, w24 0xcb3ac37b sub x27, x27, w26, sxtw After: 0x93407f1b sxtw x27, w24 0x9160037b add x27, x27, #0x800, lsl #12 ; =0x800000