[LLVMdev] Help me improve two-address code

Greg McGary greg at mcgary.org
Thu Apr 16 16:25:21 PDT 2009

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 

def add        : SDNode<"ISD::ADD"       , SDTIntBinOp   ,
                        [SDNPCommutative, SDNPAssociative]>;

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

I see no obvious (to me, anyway 8^) "copy instruction" property.  The 
insn in question is generated by copyRegToReg(), and satisfies the 
isMoveInstr() predicate.


More information about the llvm-dev mailing list