[llvm-dev] LSR/SCEV problem/question

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 29 20:48:36 PDT 2016


Hi Geoff,

Thanks for the detailed reproduction instruction -- they were very
helpful, and I can now see the bug.

Generally, I think (2) is the better solution.  It should be up to
SCEVExpander to keep its state consistent.  The fact that we're trying
to optimize instructions as we insert them makes that trickier, but I
still think that is the right invariant to have.

I don't see why (2) would be particularly ugly though (perhaps I'm not
being sufficiently imaginative :) ).  I think
IRBuilder::SetInsertPoint(Instruction *) is safe, since it always sets
BB and IP in sync with each other.  So I think we basically need to
sync things at restoreIP() (which is called only once in the file) and
at places that potentially move insertion points (like hoistIVInc)
using something like
"Builder.SetInsertPoint(&*Builder.GetInsertPoint())".  Are there any
other places that need to be fixed too?

We should also add a LSRInserter that asserts that the basic block
we're inserting into is the same as the insertee's parent.

-- Sanjoy


More information about the llvm-dev mailing list