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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 02:29:23 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
----------------
david-arm wrote:

I think the comment on this function needs updating.

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


More information about the llvm-commits mailing list