[PATCH] D118808: Loop Strength Reduce - Optimize unused IVs to final values in the exit block with SCEV

Whitney Tsang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 22 16:04:17 PST 2022


Whitney added a comment.

Is it possible to abstract the portion of the code in IndVarSimplify to simplify this code pattern, and call that function instead of creating your own `ReplaceExitPHIsWithFinalVal`?



================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5624
+    if (LCSSAPhi.getNumIncomingValues() != 1)
+      continue;
+
----------------
continue can change to break as all Phis in the same block should have the same number of incoming values. 


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5644
+      continue;
+    for (auto U : IV->users()) {
+        if (U != IVNext) {
----------------
In what situation, that IV only has a single use (`IV->getNumUses() != 1`) and one of the incoming values of `IV` is `IVNext`, but `U != IVNext`?


================
Comment at: llvm/test/Transforms/LoopStrengthReduce/remove_scev_indvars.ll:22
+for.exit:
+  %iv.prol.lcssa = phi i64 [ %indvars.iv.next.prol, %for.body ]
+  ret void
----------------
Do we want to also handle the case `%iv.prol.lcssa = phi i64 [ %indvars.iv.prol, %for.body ]`?


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

https://reviews.llvm.org/D118808



More information about the llvm-commits mailing list