[PATCH] D109845: [SCEV] Correctly propagate nowrap flags across scopes when folding invariant add through addrec

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 24 19:58:40 PDT 2021


mkazantsev added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:2808
+        auto *SinglePred = AddRecLoop->getLoopPreheader();
+        if (!SinglePred || !SinglePred->getSingleSuccessor())
+          return false;
----------------
Preheader has single successor by definition.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:2825
+          } else if (isa<SCEVConstant>(S)) {
+            return SinglePred == &SinglePred->getParent()->getEntryBlock();
+          }
----------------
Do we reject constants due to some block-related reasoning? Aren't they always available?


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:2831
+        return (FoundScope &&
+                isGuaranteedToTransferExecutionToSuccessor(SinglePred));
+      }();
----------------
Imagine the situation when inner loop is entered (and existing checks basically only test it), but always side-exits on 1st iteration in a call that is inside the inner loop. So actually whatever flags the inner AddRec has, it doesn't matter because they will never actually come in play. Will they still be propagated to outside?


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

https://reviews.llvm.org/D109845



More information about the llvm-commits mailing list