[PATCH] D145929: [LSR] Fold terminating condition not only for eq and ne

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 01:27:44 PDT 2023


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


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6942
+      // Swap successors to exit loop body if IV equals to new TermValue
+      if (BI->getSuccessor(1) != LoopLatch)
+        BI->swapSuccessors();
----------------
I don't think comparing with loop latch is the right condition here: You need to check for the loop header. In test current test cases these just happen to be the same.

Can you add a test where the loop has more than one block? Probably even just inserting a dummy unconditional `br` to split the block would be enough.


================
Comment at: llvm/test/Transforms/LoopStrengthReduce/lsr-term-fold.ll:1
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes="loop-reduce" -S -lsr-term-fold | FileCheck %s
----------------
Can you please rerun this script? The check line formatting looks a bit off.


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

https://reviews.llvm.org/D145929



More information about the llvm-commits mailing list