[LLVMdev] Unnecessary moves after sign-extension in 2-address target

Greg McGary greg at mcgary.org
Thu Apr 23 17:05:33 PDT 2009


Greg McGary wrote:

> I discovered a curious phenomenon:
>
> The copies are necessary because TwoAddressInstructionPass commutes
> the second add.  When I suppress the commute, the movs disappear and
> the code became optimal.  It seems the two-address commuter is either buggy
> or inherently short-sighted/simple-minded and paints itself into a corner.
>   

I have some understanding of what goes no here.  One of the cases where
TwoAddressInstructionPass commutes is when it can shorten the live range
of a src/dest operand.  Maybe this is good for x86, but is bad for my
CPU which has 32 GPRs, so doesn't need to sacrifice in order to reduce
register pressure.  Actually, in my small tests I haven't seen x86 suffer
from removing this class of commutations.  I'll see how things go for
x86 on some larger things in test-suite before I determine whether my
change works for x86.  If it loses for x86, it still wins for my port,
so I can make this commutation case depend on a parameter of the target.

G




More information about the llvm-dev mailing list