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

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 13 10:13:40 PDT 2021


reames added a comment.

Reverted patch due to issue caught in post commit review.  See inline.



================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1317
+  for (auto &PN : LoopHeader->phis()) {
+    auto *PreheaderIncoming = PN.getIncomingValueForBlock(LoopPreheader);
+    PN.replaceAllUsesWith(PreheaderIncoming);
----------------
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.  


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