[PATCH 0/6] x86: a few more optimizations
Jan Beulich
jbeulich@suse.com
Mon Jun 17 08:37:57 GMT 2024
On 17.06.2024 10:09, Cui, Lili wrote:
>> 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?
>
> These two ideas are so good that several people think that GCC should support these two conversions. Would you consider implementing these conversions in gcc?
Multiplication to shift conversion is already done by the compiler, afaik. As
to 1), are you suggesting the compiler may emit such code? Imo it shouldn't.
Plus, as indicated in the reply to Haochen, I view optimizations in gas as
primarily targeting hand-written code anyway. Compilers shouldn't rely on the
assembler doing further transformations.
Jan
More information about the Binutils
mailing list