[LLVMdev] Help me improve two-address code

Evan Cheng evan.cheng at apple.com
Thu Apr 16 17:07:09 PDT 2009

On Apr 16, 2009, at 4:25 PM, Greg McGary wrote:

> Evan Cheng wrote:
>> On Apr 16, 2009, at 3:17 PM, Greg McGary wrote:
>>> Is there some optimizer knob I'm not turning properly?  In more  
>>> complex
>>> cases, GCC does poorly with two-address operand choices and so  
>>> bloats
>>> the code with unnecessary register moves.  I have high hopes LLVM
>>> can do better, so this result for a simple case is bothersome.
>> Are you marking add as commutable? Are you making mov as a copy
>> instruction?
> How do I mark them?  For the commutative property, I observed this
> definition:
> def add        : SDNode<"ISD::ADD"       , SDTIntBinOp   ,
>                        [SDNPCommutative, SDNPAssociative]>;

Yes, the "target-independent" ISD::ADD node is commutative. But it  
doesn't mean the target specific instruction it is selected to has to  
be commutative.

> ... and assumed it was sufficient, since I saw no other targets making
> special arrangements.

In X86InstrInfo.td, ADD32rr (and lots others) are marked isCommutable.


> I see no obvious (to me, anyway 8^) "copy instruction" property.  The
> insn in question is generated by copyRegToReg(), and satisfies the
> isMoveInstr() predicate.
> 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