[llvm] 6eab5ca - [LSR] Early exit for RateFormula when it is already losing. NFC

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 21:02:46 PDT 2022


Author: eopXD
Date: 2022-06-01T21:02:40-07:00
New Revision: 6eab5cade71459bc187eeeb364b9a94972c05696

URL: https://github.com/llvm/llvm-project/commit/6eab5cade71459bc187eeeb364b9a94972c05696
DIFF: https://github.com/llvm/llvm-project/commit/6eab5cade71459bc187eeeb364b9a94972c05696.diff

LOG: [LSR] Early exit for RateFormula when it is already losing. NFC

This patch does not effect any behavior of the current code.

The codebase implicitly implies that `Cost::RateFormula` is only called
when the `Cost` is not in losing status, or else there may be possible
to trigger the assertion of `Cost::isValid`.

The intention here is to prevent mis-use where future development
allow `Cost` that is already loser to call `Cost::RateFormula` - Early
exit when `Cost` is already losing.

Reviewed By: Meinersbur, #loopoptwg

Differential Revision: https://reviews.llvm.org/D125670

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index e53dea5a231b9..f0a5f942578bd 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1355,6 +1355,8 @@ void Cost::RateFormula(const Formula &F,
                        const DenseSet<const SCEV *> &VisitedRegs,
                        const LSRUse &LU,
                        SmallPtrSetImpl<const SCEV *> *LoserRegs) {
+  if (isLoser())
+    return;
   assert(F.isCanonical(*L) && "Cost is accurate only for canonical formula");
   // Tally up the registers.
   unsigned PrevAddRecCost = C.AddRecCost;


        


More information about the llvm-commits mailing list