[llvm] [LoopVectorize] Use predicated version of getSmallConstantMaxTripCount (PR #109928)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 01:34:41 PDT 2024


================
@@ -3994,8 +3996,13 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
   }
 
   unsigned TC = PSE.getSE()->getSmallConstantTripCount(TheLoop);
-  unsigned MaxTC = PSE.getSE()->getSmallConstantMaxTripCount(TheLoop);
+
+  SmallVector<const SCEVPredicate *, 2> Predicates;
+  unsigned MaxTC =
+      PSE.getSE()->getSmallConstantMaxTripCount(TheLoop, &Predicates);
----------------
david-arm wrote:

Do you mean the calls to `PSE.getSE()->getPredicatedExitCount` in `LoopVectorizationLegality::isVectorizableEarlyExitLoop`? I'm not sure if we want to do exactly the same, i.e. cache the exit count for every exit. I could potentially add an equivalent method to `PredicatedScalarEvolution` that automatically adds the predicates, but probably best done in a separate patch because it's unrelated to the max trip count. What do you think?

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


More information about the llvm-commits mailing list