[PATCH] D132443: [LSR] Fold terminal condition to other IV when possible

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 10:08:13 PDT 2022


craig.topper requested changes to this revision.
craig.topper added inline comments.
This revision now requires changes to proceed.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:189
 
+static cl::opt<bool> AllowTerminalConditionFoldingAfterLSR(
+    "lsr-term-fold", cl::Hidden, cl::init(false),
----------------
Terminal -> Terminating? The word terminal does not appear in LSR prior to this patch.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6581
 
+static std::pair<bool, std::pair<PHINode *, PHINode *>>
+canFoldTermCondOfLoop(Loop *L, ScalarEvolution &SE, DominatorTree &DT,
----------------
std::tuple?


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6798
+      for (Use &U : ToHelpFold->operands()) {
+        if (ToHelpFold->getIncomingBlock(U) == LoopPreheader)
+          StartValue = cast<Value>(&U);
----------------
Is this loop just `ToHelpFold->getIncomingValueForBlock(LoopPreheader)`?


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6799
+        if (ToHelpFold->getIncomingBlock(U) == LoopPreheader)
+          StartValue = cast<Value>(&U);
+        else
----------------
Do you really need a cast here? If you do, I'd use U.get() instead.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6801
+        else
+          LoopValue = cast<Value>(&U);
+      }
----------------
Same here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132443



More information about the llvm-commits mailing list