summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-03-09 01:51:02 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-03-09 01:51:02 +0000
commit97d19bd95fb724c937cf3e32d91296fe12476ad5 (patch)
tree88c659f69bb88213c80ab1896333b65faa2e57a1 /llvm/test
parentd3488c6060efc5cc554c15d30917c25acf98eeaa (diff)
downloadbcm5719-llvm-97d19bd95fb724c937cf3e32d91296fe12476ad5.tar.gz
bcm5719-llvm-97d19bd95fb724c937cf3e32d91296fe12476ad5.zip
[SCEV] Slightly generalize getRangeViaFactoring
Building on the previous change, this generalizes ScalarEvolution::getRangeViaFactoring to work with {Ext(C?A:B)+k0,+,Ext(C?A:B)+k1} where Ext can be a zero extend, sign extend or truncate operation, and k0 and k1 are constants. llvm-svn: 262979
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll58
1 files changed, 58 insertions, 0 deletions
diff --git a/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll b/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll
index bb062919d11..8c631a42f81 100644
--- a/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll
+++ b/llvm/test/Analysis/ScalarEvolution/increasing-or-decreasing-iv.ll
@@ -188,3 +188,61 @@ loop:
leave:
ret void
}
+
+define void @f6(i1 %c) {
+; CHECK-LABEL: Classifying expressions for: @f6
+entry:
+ %start = select i1 %c, i32 127, i32 0
+ %step = select i1 %c, i32 -2, i32 0
+ br label %loop
+
+loop:
+ %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ]
+ %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ]
+; CHECK: %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ]
+; CHECK-NEXT: --> {%start,+,(1 + %step)<nuw><nsw>}<%loop> U: [0,128) S: [0,128)
+
+ %step.plus.one = add i32 %step, 1
+ %iv.next = add i32 %iv, %step.plus.one
+ %iv.sext = sext i32 %iv to i64
+; CHECK: %iv.sext = sext i32 %iv to i64
+; CHECK-NEXT: --> {(sext i32 %start to i64),+,(1 + (sext i32 %step to i64))<nsw>}<nsw><%loop> U: [0,128) S: [0,128)
+ %loop.iv.inc = add i16 %loop.iv, 1
+ %be.cond = icmp ne i16 %loop.iv.inc, 128
+ br i1 %be.cond, label %loop, label %leave
+
+leave:
+ ret void
+}
+
+define void @f7(i1 %c) {
+; CHECK-LABEL: Classifying expressions for: @f7
+entry:
+ %start = select i1 %c, i32 127, i32 0
+ %step = select i1 %c, i32 -1, i32 1
+ br label %loop
+
+loop:
+ %loop.iv = phi i16 [ 0, %entry ], [ %loop.iv.inc, %loop ]
+ %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ]
+ %iv.trunc = trunc i32 %iv to i16
+; CHECK: %iv.trunc = trunc i32 %iv to i16
+; CHECK-NEXT: --> {(trunc i32 %start to i16),+,(trunc i32 %step to i16)}<%loop> U: [0,128) S: [0,128)
+ %iv.next = add i32 %iv, %step
+
+ %iv.trunc.plus.one = add i16 %iv.trunc, 1
+; CHECK: %iv.trunc.plus.one = add i16 %iv.trunc, 1
+; CHECK-NEXT: --> {(1 + (trunc i32 %start to i16))<nuw><nsw>,+,(trunc i32 %step to i16)}<%loop> U: [1,129) S: [1,129)
+
+ %iv.trunc.plus.two = add i16 %iv.trunc, 2
+; CHECK: %iv.trunc.plus.two = add i16 %iv.trunc, 2
+; CHECK-NEXT: --> {(2 + (trunc i32 %start to i16))<nuw><nsw>,+,(trunc i32 %step to i16)}<%loop> U: [2,130) S: [2,130)
+
+ %loop.iv.inc = add i16 %loop.iv, 1
+ %be.cond = icmp ne i16 %loop.iv.inc, 128
+ br i1 %be.cond, label %loop, label %leave
+
+leave:
+ ret void
+}
+
OpenPOWER on IntegriCloud