[llvm-commits] [llvm] r142731 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/load.ll

Daniel Berlin dberlin at dberlin.org
Mon Oct 24 11:35:36 PDT 2011


On Mon, Oct 24, 2011 at 2:29 PM, Nick Lewycky <nlewycky at google.com> wrote:
> 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.
I'll paraphrase what i helped write for the GCC web page on this:
Loop closed SSA is simple:

No SSA name defined inside a loop is used outside of it.
In order to make this true, phi nodes are created at loop exits for
names defined inside the loop, but used later outside the loop.

The reason for doing this are three fold
1. A lot of optimizations are interested in exactly these values (For
example, these are exactly the values you may be able to replace with
new constant expressions)
2. IV analysis can talk about a name and you don't have to worry about
which loop they are talking about, it's always a single loop
3. it makes loop opts easier, because the set of nodes you have to
modify is contained quite nicely (otherwise, any loop opt that needs
to update uses may have to update nodes all throughout the function)




More information about the llvm-commits mailing list