[PATCH 0/6] x86: a few more optimizations
Jan Beulich
jbeulich@suse.com
Fri Jun 14 12:10:35 GMT 2024
APX {nf} insn forms present a number of interesting optimization
opportunities, often mostly for size. There are a few more that I'm
aware of, but where I'm less convinced that input code would really
ever be written like this:
1) Quite a few operations could be converted to plain MOV. For example
{nf} xor %cl, %cl
{nf} sub %cl, %cl
{nf} and $0, %cl
can all be replaced by the much shorter
mov $0, %cl
2) Certain forms of IMUL{,ZU} with a power-of-2 immediate could be
converted to SHL. This could be beneficial even when size doesn't
shrink, for SHL still having better latency/throughput.
Thoughts?
Plus: Since, even if leaving out the further ones above, there are
quite a few {nf}-specific ones, I was wondering whether it would make
sense to put those in a separate optimize_nf_encoding() function, to
somewhat limit optimize_encoding()'s growth.
Two non-{nf} ones are here in addition, as I came to think of them
while doing the preparations / work.
1: optimize left-shift-by-1
2: optimize {nf} forms of ADD/SUB with immediate of 0x80
3: optimize {nf}-form rotate-by-width-less-1
4: optimize certain {nf}-form insns to LEA
5: optimize certain {nf}-form insns to BMI2 ones
6: optimize {,V}PEXTR{D,Q} with immediate of 0
Jan
More information about the Binutils
mailing list