[llvm] [X86] Prefer andl to andb to save one byte encoding when using with bzhi or bextr (PR #86921)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 19:22:16 PDT 2024


phoebewang wrote:

> Is the 1 byte savings from the REX prefix needed to access the low register of sil/dil/bph/sph? They look to be same length for other registers.
> 
> If the register is al/eax the andl encoding is larger. https://godbolt.org/z/3xYPnjqas

Thanks for the points. I was thinking 8-bit register always has a longer encoding. So the thing is AL has one byte shorter, BL/CL/DL and R8~R15B is the same, while SIL/DIL/BPL/SPL has one byter longer. Maybe it still looks a win in general?

One thing I didn't mention is the reporter thinks this can also avoid false dependence stalls, but I didn't find it the SOM nor in hasPartialRegUpdate. The weak evidence is GCC always generates 32-bit AND, even in 32-bit mode https://godbolt.org/z/hvvM3fzM9

Do you think it's worth for this change?

https://github.com/llvm/llvm-project/pull/86921


More information about the llvm-commits mailing list