[PATCH] D109596: [IndVars] Replace PHIs if loop exits on 1st iteration

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 17 02:44:28 PDT 2021


mkazantsev added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1317
+  for (auto &PN : LoopHeader->phis()) {
+    auto *PreheaderIncoming = PN.getIncomingValueForBlock(LoopPreheader);
+    PN.replaceAllUsesWith(PreheaderIncoming);
----------------
reames wrote:
> As written, this code does not preserve LCSSA.  Consider the case where we have two sibling loops and the header of the second is directly an exit block of the first.  This is not loop simplify form (i.e. no preheader), but it is a possible case.  
Philip, there is an assert on line 1741 that the loop is in simplify form. I don't think the situation you are referring to is even possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109596



More information about the llvm-commits mailing list