[llvm-commits] [llvm] r140966 - in /llvm/trunk/lib/Transforms: InstCombine/InstCombineSelect.cpp Utils/CloneFunction.cpp
Nick Lewycky
nicholas at mxc.ca
Sun Oct 2 02:12:59 PDT 2011
Author: nicholas
Date: Sun Oct 2 04:12:55 2011
New Revision: 140966
URL: http://llvm.org/viewvc/llvm-project?rev=140966&view=rev
Log:
Enhance a couple places where we were doing constant folding of instructions,
but not load instructions. Noticed by inspection.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=140966&r1=140965&r2=140966&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Sun Oct 2 04:12:55 2011
@@ -324,9 +324,14 @@
}
// All operands were constants, fold it.
- if (ConstOps.size() == I->getNumOperands())
+ if (ConstOps.size() == I->getNumOperands()) {
+ if (LoadInst *LI = dyn_cast<LoadInst>(I))
+ if (!LI->isVolatile())
+ return ConstantFoldLoadFromConstPtr(ConstOps[0], TD);
+
return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
ConstOps, TD);
+ }
}
return 0;
Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=140966&r1=140965&r2=140966&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Sun Oct 2 04:12:55 2011
@@ -331,12 +331,8 @@
TD);
if (const LoadInst *LI = dyn_cast<LoadInst>(I))
- if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[0]))
- if (!LI->isVolatile() && CE->getOpcode() == Instruction::GetElementPtr)
- if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
- if (GV->isConstant() && GV->hasDefinitiveInitializer())
- return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(),
- CE);
+ if (!LI->isVolatile())
+ return ConstantFoldLoadFromConstPtr(Ops[0], TD);
return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Ops, TD);
}
More information about the llvm-commits
mailing list