blob: 436840ae907502fe1c37ce25e824f88e808635d0 [file] [log] [blame]
Dan Gohman3c7d3082009-09-11 18:01:28 +00001; RUN: opt < %s -indvars -S > %t
Dan Gohman28055122009-05-12 02:17:14 +00002; RUN: grep phi %t | count 4
3; RUN: grep {= phi i32} %t | count 4
4; RUN: not grep {sext i} %t
5; RUN: not grep {zext i} %t
6; RUN: not grep {trunc i} %t
7; RUN: not grep {add i8} %t
8; PR1301
9
10; Do a bunch of analysis and prove that the loops can use an i32 trip
11; count without casting.
12
13; ModuleID = 'ada.bc'
14target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
15target triple = "i686-pc-linux-gnu"
16
17define void @kinds__sbytezero([256 x i32]* nocapture %a) nounwind {
18bb.thread:
19 %tmp46 = getelementptr [256 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
20 store i32 0, i32* %tmp46
21 br label %bb
22
23bb: ; preds = %bb, %bb.thread
24 %i.0.reg2mem.0 = phi i8 [ -128, %bb.thread ], [ %tmp8, %bb ] ; <i8> [#uses=1]
25 %tmp8 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=3]
26 %tmp1 = sext i8 %tmp8 to i32 ; <i32> [#uses=1]
27 %tmp3 = add i32 %tmp1, 128 ; <i32> [#uses=1]
28 %tmp4 = getelementptr [256 x i32]* %a, i32 0, i32 %tmp3 ; <i32*> [#uses=1]
29 store i32 0, i32* %tmp4
30 %0 = icmp eq i8 %tmp8, 127 ; <i1> [#uses=1]
31 br i1 %0, label %return, label %bb
32
33return: ; preds = %bb
34 ret void
35}
36
37define void @kinds__ubytezero([256 x i32]* nocapture %a) nounwind {
38bb.thread:
39 %tmp35 = getelementptr [256 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
40 store i32 0, i32* %tmp35
41 br label %bb
42
43bb: ; preds = %bb, %bb.thread
44 %i.0.reg2mem.0 = phi i8 [ 0, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=1]
45 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=3]
46 %tmp1 = zext i8 %tmp7 to i32 ; <i32> [#uses=1]
47 %tmp3 = getelementptr [256 x i32]* %a, i32 0, i32 %tmp1 ; <i32*> [#uses=1]
48 store i32 0, i32* %tmp3
49 %0 = icmp eq i8 %tmp7, -1 ; <i1> [#uses=1]
50 br i1 %0, label %return, label %bb
51
52return: ; preds = %bb
53 ret void
54}
55
56define void @kinds__srangezero([21 x i32]* nocapture %a) nounwind {
57bb.thread:
58 br label %bb
59
60bb: ; preds = %bb, %bb.thread
61 %i.0.reg2mem.0 = phi i8 [ -10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2]
62 %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1]
63 %tmp4 = add i32 %tmp12, 10 ; <i32> [#uses=1]
64 %tmp5 = getelementptr [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1]
65 store i32 0, i32* %tmp5
66 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2]
67 %0 = icmp sgt i8 %tmp7, 10 ; <i1> [#uses=1]
68 br i1 %0, label %return, label %bb
69
70return: ; preds = %bb
71 ret void
72}
73
74define void @kinds__urangezero([21 x i32]* nocapture %a) nounwind {
75bb.thread:
76 br label %bb
77
78bb: ; preds = %bb, %bb.thread
79 %i.0.reg2mem.0 = phi i8 [ 10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2]
80 %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1]
81 %tmp4 = add i32 %tmp12, -10 ; <i32> [#uses=1]
82 %tmp5 = getelementptr [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1]
83 store i32 0, i32* %tmp5
84 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2]
85 %0 = icmp sgt i8 %tmp7, 30 ; <i1> [#uses=1]
86 br i1 %0, label %return, label %bb
87
88return: ; preds = %bb
89 ret void
90}