[PATCH] D40953: [SCEV] Fix predicate usage in computeExitLimitFromICmp
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 04:20:24 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320142: [SCEV] Fix predicate usage in computeExitLimitFromICmp (authored by mkazantsev).
Changed prior to commit:
https://reviews.llvm.org/D40953?vs=125943&id=126123#toc
Repository:
rL LLVM
https://reviews.llvm.org/D40953
Files:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/test/Analysis/ScalarEvolution/shift-op.ll
Index: llvm/trunk/test/Analysis/ScalarEvolution/shift-op.ll
===================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/shift-op.ll
+++ llvm/trunk/test/Analysis/ScalarEvolution/shift-op.ll
@@ -160,5 +160,24 @@
ret void
}
+define void @test9() {
+; CHECK-LABEL: Determining loop execution counts for: @test9
+; CHECK: Loop %loop: Unpredictable max backedge-taken count.
+
+; This is an infinite loop, make sure that it recognized as such.
+
+entry:
+ br label %loop
+
+leave:
+ ret void
+
+loop:
+ %iv = phi i32 [ -20, %entry ], [ %iv.shift, %loop ]
+ %iv.shift = ashr i32 %iv, 1
+ %exit.cond = icmp sgt i32 %iv, -1
+ br i1 %exit.cond, label %leave, label %loop
+}
+
!0 = !{i32 0, i32 50000}
!1 = !{i32 -5000, i32 -1}
Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
@@ -7074,6 +7074,7 @@
Cond = ExitCond->getPredicate();
else
Cond = ExitCond->getInversePredicate();
+ const ICmpInst::Predicate OriginalCond = Cond;
// Handle common loops like: for (X = "string"; *X; ++X)
if (LoadInst *LI = dyn_cast<LoadInst>(ExitCond->getOperand(0)))
@@ -7157,7 +7158,7 @@
return ExhaustiveCount;
return computeShiftCompareExitLimit(ExitCond->getOperand(0),
- ExitCond->getOperand(1), L, Cond);
+ ExitCond->getOperand(1), L, OriginalCond);
}
ScalarEvolution::ExitLimit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40953.126123.patch
Type: text/x-patch
Size: 1597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171208/30aaa966/attachment.bin>
More information about the llvm-commits
mailing list