[llvm-commits] [llvm] r142731 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/load.ll
Duncan Sands
baldrick at free.fr
Sun Oct 23 07:15:00 PDT 2011
Hi Nick,
> - if (const CmpInst *CI = dyn_cast<CmpInst>(I))
> + if (CmpInst *CI = dyn_cast<CmpInst>(I))
> return ConstantFoldCompareInstOperands(CI->getPredicate(), Operands[0],
> Operands[1], TD);
> + if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
> + if (!LI->isVolatile())
> + return ConstantFoldLoadFromConstPtr(Operands[0], TD);
> + }
> return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Operands, TD);
maybe you could use instsimplify here? It does constant folding and more
besides. It can break LCSSA form, so you may need to check for that (if so,
check out the loop transform users of instsimplify to see how).
> @@ -4993,7 +5109,10 @@
> if (const CmpInst *CI = dyn_cast<CmpInst>(I))
> C = ConstantFoldCompareInstOperands(CI->getPredicate(),
> Operands[0], Operands[1], TD);
> - else
> + else if (const LoadInst *LI = dyn_cast<LoadInst>(I)) {
> + if (!LI->isVolatile())
> + C = ConstantFoldLoadFromConstPtr(Operands[0], TD);
> + } else
> C = ConstantFoldInstOperands(I->getOpcode(), I->getType(),
> Operands, TD);
> if (!C) return V;
Likewise.
Ciao, Duncan.
More information about the llvm-commits
mailing list