[PATCH] D57428: [SCEV] Guard movement of insertion point for loop-invariants (take 2)

Warren Ristow via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 19 17:02:23 PST 2019


wristow added a comment.

In D57428#1397625 <https://reviews.llvm.org/D57428#1397625>, @mkazantsev wrote:

> I did not look into this too deeply, but the problem you're describing sounds like it can be solved by setting `InsertPt` to `getFirstNonPHI` at some point.


Thanks for the comment @mkazantsev.  I think the two lines I added (relative to the commit of r347934, which exposed this `PHINode` issue):

  if (isa<PHINode>(*InsertPt))
    InsertPt = &*InsertPt->getParent()->getFirstInsertionPt();

are doing essentially that (with a slight tweak).  Specifically, that call to `getFirstInsertionPt()` does call `getFirstNonPHI()`, and then also checks to see whether that gets to a LandingPad instruction (and if so, skips over the LandingPad, too).  Since the other adjustments to `InsertPt` in this code also use this "wrapper" of `getFirstInsertionPt()` rather than calling `getFirstNonPHI()` directly, I felt safer using that approach.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57428/new/

https://reviews.llvm.org/D57428





More information about the llvm-commits mailing list