[PATCH] D78279: [SimpleLoopUnswitch] Add non-empty unreachable block check to exit cases removed.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 19:55:49 PDT 2020


chandlerc added a comment.

Might also be good to explain a bit of *how* this fixes the PR to the commit log (or bug) for posterity. It seemed to surprise both of us that this was the fix when talking through the code, I suspect a future reader may benefit from having a log of what went on here.



================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:613-614
   SmallVector<int, 4> ExitCaseIndices;
-  for (auto Case : SI.cases()) {
-    auto *SuccBB = Case.getCaseSuccessor();
-    if (!L.contains(SuccBB) &&
-        areLoopExitPHIsLoopInvariant(L, *ParentBB, *SuccBB))
+  for (auto Case : SI.cases())
+    if (ArePhisLoopInvAndNotUnreachable(Case.getCaseSuccessor()))
       ExitCaseIndices.push_back(Case.getCaseIndex());
----------------
Comment about the fact that the default and case conditions *must* be the exact same? Otherwise I fear we'll add back this bug some day soon...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78279





More information about the llvm-commits mailing list