llvm.org GIT mirror
Canonicalize ConstantInts to the right operand of commutative operators. The test difference is just due to the multiplication operands being commuted (and thus requiring a more elaborate match). In optimized code, that expression would be folded. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96816 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
3 changed file(s) with 7 addition(s) and 3 deletion(s).
 793 793 // it is casted back to a pointer, see if the expression can be 794 794 // converted into a GEP. 795 795 if (CE->getOpcode() == Instruction::Add) 796 if (ConstantInt *L = dyn_cast(CE->getOperand(0))) 797 if (ConstantExpr *R = dyn_cast>(CE->getOperand(1)))⏎ 796 if (ConstantInt *L = dyn_cast>(CE->getOperand(1)))⏎ 797 if (ConstantExpr *R = dyn_cast(CE->getOperand(0))) 798 798 if (R->getOpcode() == Instruction::PtrToInt) 799 799 if (GlobalVariable *GV = 800 800 dyn_cast(R->getOperand(0))) {
 1104 1104 return ConstantExpr::getLShr(C1, C2); 1105 1105 break; 1106 1106 } 1107 } else if (isa(C1)) { 1108 // If C1 is a ConstantInt and C2 is not, swap the operands. 1109 if (Instruction::isCommutative(Opcode)) 1110 return ConstantExpr::get(Opcode, C2, C1); 1107 1111 } 1108 1112 1109 1113 // At this point we know neither constant is an UndefValue.
 8 8 9 9 ; CHECK: .globl x 10 10 ; CHECK: x: 11 ; CHECK: .quad 3⏎ 11 ; CHECK: .quad ((0+1)&4294967295)*3⏎ 12 12 13 13 @x = global i64 mul (i64 3, i64 ptrtoint (i2* getelementptr (i2* null, i64 1) to i64))