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 a SUB instruction on ARM64. Constants in this range do not need to be sign extended, so 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: 0x52a00099 mov w25, #0x40000 ; =262144 0x93407f7a sxtw x26, w27 0xcb39c35a sub x26, x26, w25, sxtw After: 0x93407f7a sxtw x26, w27 0xd141035a sub x26, x26, #0x40, lsl #12 ; =0x40000