[llvm] [LV] Scale block costs using BranchFrequencyInfo (PR #71793)
    Florian Hahn via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Jan 18 03:01:08 PST 2024
    
    
  
================
@@ -401,14 +401,23 @@ static bool hasIrregularType(Type *Ty, const DataLayout &DL) {
   return DL.getTypeAllocSizeInBits(Ty) != DL.getTypeSizeInBits(Ty);
 }
 
-/// A helper function that returns the reciprocal of the block probability of
-/// predicated blocks. If we return X, we are assuming the predicated block
-/// will execute once for every X iterations of the loop header.
-///
-/// TODO: We should use actual block probability here, if available. Currently,
-///       we always assume predicated blocks have a 50% chance of executing.
+/// A helper function that returns the reciprocal of the block probability of a 
+/// predicated block. Without further information, we assume a prob. of 50%.
 static unsigned getReciprocalPredBlockProb() { return 2; }
 
+/// A helper function that returns the reciprocal of the block probability of a 
+// predicated block by comparing its BlockFrequency to that of the loop header.
+static unsigned getReciprocalPredBlockProb(BlockFrequencyInfo *BFI,
----------------
fhahn wrote:
Is there a reason some uses still directly use `getReciprocalPredBlockProb`?
https://github.com/llvm/llvm-project/pull/71793
    
    
More information about the llvm-commits
mailing list