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

Michael Berg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 23 19:47:38 PDT 2022


mcberg2021 added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6589
+
+  if (!LoopLatch || !LoopPreheader || !SE.hasLoopInvariantBackedgeTakenCount(L))
+    return CantFold;
----------------
With isLoopSimplifyForm() you do not need to check for LoopLatch and LoopPreheader here, it already does.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6608
+
+    while (V->getNumUses() == 1)
+      V = *V->user_begin();
----------------
What happens if there is more than one use here?  Why not use hasOneUse() and return if false?


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6617
+    for (User *U : V->users()) {
+      while (U->getNumUses() == 1) {
+        if (isa<PHINode>(U))
----------------
If you use hasOneUse, you will not need a loop here, you can still get the beginning and check


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