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