[PATCH] D122457: [LSR] Fix canonicalization formula and its checker.

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 28 22:08:33 PDT 2022


mkazantsev accepted this revision.
mkazantsev added a comment.
This revision is now accepted and ready to land.

LGTM with nits.



================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:482
 
+static bool SCEVConatinsAddRecWithLoop(const SCEV *S, const Loop &L) {
+  return SCEVExprContains(S, [&L](const SCEV *S) {
----------------
nit: naming convention for functions broken here, I suggest `containsAddRecDependentOnLoop`.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:507
   // loop, we want to swap the reg in BaseRegs with ScaledReg.
-  auto I = find_if(BaseRegs, [&](const SCEV *S) {
-    return isa<const SCEVAddRecExpr>(S) &&
-           (cast<SCEVAddRecExpr>(S)->getLoop() == &L);
+  return none_of(BaseRegs, [&](const SCEV *S) {
+    return SCEVConatinsAddRecWithLoop(S, L);
----------------
nit: I think we can capture `[&L]` only.


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

https://reviews.llvm.org/D122457



More information about the llvm-commits mailing list