[llvm-commits] [llvm] r60748 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll
Nick Lewycky
nicholas at mxc.ca
Mon Dec 8 23:25:05 PST 2008
Author: nicholas
Date: Tue Dec 9 01:25:04 2008
New Revision: 60748
URL: http://llvm.org/viewvc/llvm-project?rev=60748&view=rev
Log:
It's easy to handle SLE/SGE when the loop has a unit stride.
Added:
llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=60748&r1=60747&r2=60748&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Dec 9 01:25:04 2008
@@ -2924,8 +2924,12 @@
if (!R)
return true;
- if (isSigned)
+ if (isSigned) {
+ if (SC->getValue()->isOne())
+ return R->getValue()->isMaxValue(true);
+
return true; // XXX: because we don't have an sdiv scev.
+ }
// If negative, it wraps around every iteration, but we don't care about that.
APInt S = SC->getValue()->getValue().abs();
Added: llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll?rev=60748&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll (added)
+++ llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll Tue Dec 9 01:25:04 2008
@@ -0,0 +1,24 @@
+; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {255 iterations}
+
+define i32 @foo(i32 %x, i32 %y, i32* %lam, i32* %alp) nounwind {
+bb1.thread:
+ br label %bb1
+
+bb1: ; preds = %bb1, %bb1.thread
+ %indvar = phi i32 [ 0, %bb1.thread ], [ %indvar.next, %bb1 ] ; <i32> [#uses=4]
+ %i.0.reg2mem.0 = sub i32 255, %indvar ; <i32> [#uses=2]
+ %0 = getelementptr i32* %alp, i32 %i.0.reg2mem.0 ; <i32*> [#uses=1]
+ %1 = load i32* %0, align 4 ; <i32> [#uses=1]
+ %2 = getelementptr i32* %lam, i32 %i.0.reg2mem.0 ; <i32*> [#uses=1]
+ store i32 %1, i32* %2, align 4
+ %3 = sub i32 254, %indvar ; <i32> [#uses=1]
+ %4 = icmp slt i32 %3, 0 ; <i1> [#uses=1]
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
+ br i1 %4, label %bb2, label %bb1
+
+bb2: ; preds = %bb1
+ %tmp10 = mul i32 %indvar, %x ; <i32> [#uses=1]
+ %z.0.reg2mem.0 = add i32 %tmp10, %y ; <i32> [#uses=1]
+ %5 = add i32 %z.0.reg2mem.0, %x ; <i32> [#uses=1]
+ ret i32 %5
+}
More information about the llvm-commits
mailing list