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

Evan Cheng evan.cheng at apple.com
Tue Apr 21 22:03:56 PDT 2009

On Apr 21, 2009, at 4:02 PM, Greg McGary wrote:

> Dan Gohman wrote:
>> On Apr 19, 2009, at 6:15 PM, Greg McGary wrote:
>>> Because sextb_r and sextw_r have destination tied to source  
>>> operands,
>>> TwoAddressInstructionPass thinks it needs a copy.  However, since  
>>> the
>>> sext kills its source, the copy is unnecessary.  Why does this  
>>> happen?
>>> Is TwoAddressInstructionPass relying on a later pass to notice this
>>> and
>>> transform it again?
>> Yes, the later pass is the coalescer. It would be worthwhile to
>> understand why it is not coalescing the copies.
> 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.
> How do you recommend I approach this problem?

You can try to identify the problem in 2addr pass and try to provide  
us with a patch. Or file a bugzilla with a reproducible test case.

> G
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list