[PATCH] D13974: [IndVarSimplify] Rewrite loop exit values with their initial values from loop preheader

Chen Li via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 26 23:25:33 PDT 2015


chenli added inline comments.

================
Comment at: lib/Transforms/Scalar/IndVarSimplify.cpp:736
@@ +735,3 @@
+        if (auto *BI = dyn_cast<BranchInst>(TermInst)) {
+          if (!BI->isConditional())
+            continue;
----------------
sanjoy wrote:
> Note: this transform is also valid for unconditional branches (since `br label %foo` is equivalent to `br true label %foo label %foo`).
> 
> Actually, thinking about it, I think we can pretty much `assert(BI->isConditional())` (IOW you don't need the check since `BI->getCondition()` will have the same assert it in).  (Please verify this) I think you cannot have an unconditional branch from a block `B` in the loop to a loop exit since then `B` will not be connected to the header (i.e. there won't be a path from `B` to the loop header) and hence `B` won't be part of the loop leading to a contradiction.
I think you can not have an unconditional branch in B or B will be the loop exit. I will remove the check and run some test through the test cases. 


http://reviews.llvm.org/D13974





More information about the llvm-commits mailing list