[llvm-dev] LSR/SCEV problem/question

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 24 14:05:46 PDT 2016


Hi Geoff,

Firstly, I think it will be great if you have a small reproducer of
this issue (which I can make fail after re-applying D18001 to ToT).

> I’ve run into what appears to be a bug in ScalarEvolution, but I’m not sure
> if it is instead caused by me missing an implicit assumption between LSR and
> SCEV.
>
> This issue is caused by the change D18001, which is an attempt to increase
> SCEV-inserted instruction re-use by picking a more canonical insertion
> position in the case where a new insert position block is not found.
>
> The problem I have run into with this change is that it causes an insert
> position instruction to be chosen which is later hoisted into a different
> block by  SCEVExpander::hoistIVInc().  This in turn makes the SCEVExpander

When is the insert position moved?  IOW, what is the "timeline" of
events?

There are two calls to hoistIVInc in SCEVExpander, in
getAddRecExprPHILiterally and in replaceCongruentIVs -- which one is
the problematic case?

> Builder InsertPt inconsistent (the instruction and block end up not
> matching), which leads to an invalid instruction being inserted (with its
> parent != its containing block).

-- Sanjoy


More information about the llvm-dev mailing list