aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-02-22 22:43:23 +0000
committerDan Gohman <gohman@apple.com>2010-02-22 22:43:23 +0000
commit0e488b3d1c9293bbf2d64d0ecc4d6339f9100351 (patch)
tree9d3893eb6a32ae3b37608348ef4e433aefee996c /lib/Analysis
parent418b5683363bade8a6f924f753fa76d8c752be2c (diff)
downloadexternal_llvm-0e488b3d1c9293bbf2d64d0ecc4d6339f9100351.zip
external_llvm-0e488b3d1c9293bbf2d64d0ecc4d6339f9100351.tar.gz
external_llvm-0e488b3d1c9293bbf2d64d0ecc4d6339f9100351.tar.bz2
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
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/ConstantFolding.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index f3f9a51..1d23fe0 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -794,8 +794,8 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
// it is casted back to a pointer, see if the expression can be
// converted into a GEP.
if (CE->getOpcode() == Instruction::Add)
- if (ConstantInt *L = dyn_cast<ConstantInt>(CE->getOperand(0)))
- if (ConstantExpr *R = dyn_cast<ConstantExpr>(CE->getOperand(1)))
+ if (ConstantInt *L = dyn_cast<ConstantInt>(CE->getOperand(1)))
+ if (ConstantExpr *R = dyn_cast<ConstantExpr>(CE->getOperand(0)))
if (R->getOpcode() == Instruction::PtrToInt)
if (GlobalVariable *GV =
dyn_cast<GlobalVariable>(R->getOperand(0))) {