[llvm-commits] [llvm] r142731 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/load.ll
Nick Lewycky
nlewycky at google.com
Mon Oct 24 11:29:04 PDT 2011
On 23 October 2011 07:15, Duncan Sands <baldrick at free.fr> wrote:
> 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 y so,
> check out the loop transform users of instsimplify to seou may need to
> check for that (ife how).
As far as I can see, LCSSA isn't documented and I don't understand it well
enough to know whether I'm preserving it or breaking it etc. I know it
involves creating 1-operand PHI nodes in strategic places and that's about
it.
Are there cases where InstructionSimplify will return a Constant that the
constant folder won't? This code is entirely based off of a mapping to
Constant*, so instsimplify won't help without more refactoring.
That refactoring would be scary because while we can represent the arbitrary
values, we'll find ourselves effectively unrolling the loop as we build up a
larger and larger SCEV expression. I'd like to leave unrolling to the
unrolling pass.
Nick
> @@ -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.
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111024/b94cd95c/attachment.html>
More information about the llvm-commits
mailing list