[llvm] [Analysis] Teach isDereferenceableAndAlignedInLoop about SCEV predicates (PR #106562)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 08:24:12 PDT 2024


================
@@ -8604,15 +8612,22 @@ const SCEV *ScalarEvolution::BackedgeTakenInfo::getSymbolicMax(
 }
 
 /// getConstantMax - Get the constant max backedge taken count for the loop.
-const SCEV *
-ScalarEvolution::BackedgeTakenInfo::getConstantMax(ScalarEvolution *SE) const {
-  auto PredicateNotAlwaysTrue = [](const ExitNotTakenInfo &ENT) {
-    return !ENT.hasAlwaysTruePredicate();
-  };
-
-  if (!getConstantMax() || any_of(ExitNotTaken, PredicateNotAlwaysTrue))
+const SCEV *ScalarEvolution::BackedgeTakenInfo::getConstantMax(
+    ScalarEvolution *SE,
+    SmallVectorImpl<const SCEVPredicate *> *Predicates) const {
+  if (!getConstantMax())
     return SE->getCouldNotCompute();
 
+  for (const auto &ENT : ExitNotTaken)
+    if (!ENT.hasAlwaysTruePredicate()) {
+      if (!Predicates)
+        return SE->getCouldNotCompute();
+      else {
----------------
david-arm wrote:

If this is a cleaner and/or more efficient way there are a few other places we can clean up too.

https://github.com/llvm/llvm-project/pull/106562


More information about the llvm-commits mailing list