blob: 9e635fdc0067b135351b8ae78277edfff2c47140 [file] [log] [blame]
Andrew Trick4086bb52011-06-28 06:34:10 +00001; RUN: opt < %s -indvars -S | FileCheck %s
2; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
3;
Dan Gohman81db61a2009-05-12 02:17:14 +00004; PR1301
5
6; Do a bunch of analysis and prove that the loops can use an i32 trip
7; count without casting.
Andrew Trick4086bb52011-06-28 06:34:10 +00008;
9; Note that all four functions should actually be converted to
10; memset. However, this test case validates indvars behavior. We
11; don't check that phis are "folded together" because that is a job
12; for loop strength reduction. But indvars must remove sext, zext,
13; trunc, and add i8.
14;
15; CHECK-NOT: {{sext|zext|trunc|add i8}}
Dan Gohman81db61a2009-05-12 02:17:14 +000016
17; ModuleID = 'ada.bc'
Andrew Trick5fd5b122011-03-18 16:50:32 +000018target 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-n:8:16:32"
Dan Gohman81db61a2009-05-12 02:17:14 +000019target triple = "i686-pc-linux-gnu"
20
21define void @kinds__sbytezero([256 x i32]* nocapture %a) nounwind {
22bb.thread:
23 %tmp46 = getelementptr [256 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
24 store i32 0, i32* %tmp46
25 br label %bb
26
27bb: ; preds = %bb, %bb.thread
28 %i.0.reg2mem.0 = phi i8 [ -128, %bb.thread ], [ %tmp8, %bb ] ; <i8> [#uses=1]
29 %tmp8 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=3]
30 %tmp1 = sext i8 %tmp8 to i32 ; <i32> [#uses=1]
31 %tmp3 = add i32 %tmp1, 128 ; <i32> [#uses=1]
32 %tmp4 = getelementptr [256 x i32]* %a, i32 0, i32 %tmp3 ; <i32*> [#uses=1]
33 store i32 0, i32* %tmp4
34 %0 = icmp eq i8 %tmp8, 127 ; <i1> [#uses=1]
35 br i1 %0, label %return, label %bb
36
37return: ; preds = %bb
38 ret void
39}
40
41define void @kinds__ubytezero([256 x i32]* nocapture %a) nounwind {
42bb.thread:
43 %tmp35 = getelementptr [256 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
44 store i32 0, i32* %tmp35
45 br label %bb
46
47bb: ; preds = %bb, %bb.thread
48 %i.0.reg2mem.0 = phi i8 [ 0, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=1]
49 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=3]
50 %tmp1 = zext i8 %tmp7 to i32 ; <i32> [#uses=1]
51 %tmp3 = getelementptr [256 x i32]* %a, i32 0, i32 %tmp1 ; <i32*> [#uses=1]
52 store i32 0, i32* %tmp3
53 %0 = icmp eq i8 %tmp7, -1 ; <i1> [#uses=1]
54 br i1 %0, label %return, label %bb
55
56return: ; preds = %bb
57 ret void
58}
59
60define void @kinds__srangezero([21 x i32]* nocapture %a) nounwind {
61bb.thread:
62 br label %bb
63
64bb: ; preds = %bb, %bb.thread
65 %i.0.reg2mem.0 = phi i8 [ -10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2]
66 %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1]
67 %tmp4 = add i32 %tmp12, 10 ; <i32> [#uses=1]
68 %tmp5 = getelementptr [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1]
69 store i32 0, i32* %tmp5
70 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2]
71 %0 = icmp sgt i8 %tmp7, 10 ; <i1> [#uses=1]
72 br i1 %0, label %return, label %bb
73
74return: ; preds = %bb
75 ret void
76}
77
78define void @kinds__urangezero([21 x i32]* nocapture %a) nounwind {
79bb.thread:
80 br label %bb
81
82bb: ; preds = %bb, %bb.thread
83 %i.0.reg2mem.0 = phi i8 [ 10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2]
84 %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1]
85 %tmp4 = add i32 %tmp12, -10 ; <i32> [#uses=1]
86 %tmp5 = getelementptr [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1]
87 store i32 0, i32* %tmp5
88 %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2]
89 %0 = icmp sgt i8 %tmp7, 30 ; <i1> [#uses=1]
90 br i1 %0, label %return, label %bb
91
92return: ; preds = %bb
93 ret void
94}