[llvm] [LoopRotate] Set loop back edge weight to not less than exit weight (PR #86496)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 23:01:26 PDT 2024


================
@@ -347,9 +347,19 @@ static void updateBranchWeights(BranchInst &PreHeaderBI, BranchInst &LoopBI,
         // probabilities as if there are only 0-trip and 1-trip cases.
         ExitWeight0 = OrigLoopExitWeight - OrigLoopBackedgeWeight;
       }
+    } else {
+      if (OrigLoopExitWeight > OrigLoopBackedgeWeight) {
+        LLVM_DEBUG(
+            dbgs() << "WARNING: Bad loop back edge weight. Adjust it from "
+                   << OrigLoopBackedgeWeight << " to " << OrigLoopExitWeight
+                   << "\n");
----------------
WenleiHe wrote:

I don't think we need debug print warning for this. There is a lot of guessing and fixing already in the heuristic above, and it'd be inconsistent to just print debug warning for this case.

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


More information about the llvm-commits mailing list