[llvm] [VPlan] Don't apply predication discount to non-originally-predicated blocks (PR #160449)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 16 02:11:40 PDT 2025


================
@@ -1249,6 +1249,25 @@ class LoopVectorizationCostModel {
   /// Superset of instructions that return true for isScalarWithPredication.
   bool isPredicatedInst(Instruction *I) const;
 
+  /// A helper function that returns how much we should divide the cost of a
+  /// predicated block by. Typically this is the reciprocal of the block
+  /// probability, i.e. if we return X we are assuming the predicated block will
+  /// execute once for every X iterations of the loop header so the block should
+  /// only contribute 1/X of its cost to the total cost calculation, but when
+  /// optimizing for code size it will just be 1 as code size costs don't depend
+  /// on execution probabilities.
+  ///
+  /// TODO: We should use actual block probability here, if available.
+  /// Currently, we always assume predicated blocks have a 50% chance of
+  /// executing.
+  inline unsigned
----------------
lukel97 wrote:

I've updated the comment in cf6b43532792f46850c158c54c9dc28c912b7148 to mention that tail-folded predication doesn't count in this case

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


More information about the llvm-commits mailing list