[PATCH] D126043: [LSR] Drop LSR solution if it is less profitable than baseline

Yueh-Ting (eop) Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 20:09:01 PDT 2022


eopXD added a comment.

@Meinersbur  Thank you for the review. I'll update when pre-commit patches (D125670 <https://reviews.llvm.org/D125670> and D126350 <https://reviews.llvm.org/D126350>) land.



================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:3373
+    if (!BaselineCost.isLoser())
+      BaselineCost.RateFormula(F, Regs, VisitedRegs, LU);
+
----------------
Meinersbur wrote:
> Since SCEV subexpressions can be reused by multiple instructions, doesn't this mean that this is overestimating the baseline cost?
Yes you are right, we should prevent repeating RateFormula hen multiple `IVStrideUse` matches the same `LU`. Let me update my code.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5159
+
+  if (!SolutionCost.isLess(const_cast<Cost &>(BaselineCost))) {
+    LLVM_DEBUG(dbgs() << "\n"
----------------
Meinersbur wrote:
> Instead of the const cast, would it be possible to make `Cost::isLess` accept a const object?
Created D126350.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126043/new/

https://reviews.llvm.org/D126043



More information about the llvm-commits mailing list