mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-02 08:54:15 +00:00
17db359979
More efficient code can be generated if the shift amount is known at compile time. Similar optimizations were present in JitArm64 already, but were missing in Jit64. - By using an 8-bit immediate we can eliminate the need for ECX as a scratch register, thereby reducing register pressure and occasionally eliminating a spill. Before: B9 18 00 00 00 mov ecx,18h 45 8B C1 mov r8d,r9d 49 D3 E8 shr r8,cl After: 45 8B C1 mov r8d,r9d 41 C1 E8 18 shr r8d,18h - PowerPC has strange shift amount masking behavior which is emulated using 64-bit shifts, even though we only care about a 32-bit result. If the shift amount is known, we can handle this special case separately, and use 32-bit shift instructions otherwise. Before: B9 F8 FF FF FF mov ecx,0FFFFFFF8h 45 8B C1 mov r8d,r9d 49 D3 E8 shr r8,cl After: Nothing, register is set to constant zero. - A shift by zero becomes a simple MOV. Before: B9 00 00 00 00 mov ecx,0 45 8B C1 mov r8d,r9d 49 D3 E8 shr r8,cl After: 45 8B C1 mov r8d,r9d