Add test case for PR 1154.
[oota-llvm.git] / test / Transforms / LoopRotate / pr1154.ll
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -std-compile-opts | llvm-dis | %prcontext strstr 2 | grep -v declare |grep "bb36.outer:"
2 @str = internal constant [68 x i8] c"Dot. date. datum. 123. Some more doubtful demonstration dummy data.\00"            ; <[68 x i8]*> [#uses=1]
3 @str1 = internal constant [5 x i8] c"ummy\00"           ; <[5 x i8]*> [#uses=1]
4 @str2 = internal constant [6 x i8] c" data\00"          ; <[6 x i8]*> [#uses=1]
5 @str3 = internal constant [3 x i8] c"by\00"             ; <[3 x i8]*> [#uses=1]
6
7 i32 @stringSearch_Clib(i32 %count) {
8 entry:
9         %count_addr = alloca i32                ; <i32*> [#uses=2]
10         %retval = alloca i32, align 4           ; <i32*> [#uses=2]
11         %tmp = alloca i32, align 4              ; <i32*> [#uses=2]
12         %i = alloca i32, align 4                ; <i32*> [#uses=5]
13         %c = alloca i32, align 4                ; <i32*> [#uses=9]
14         %j = alloca i32, align 4                ; <i32*> [#uses=4]
15         %p = alloca i8*, align 4                ; <i8**> [#uses=6]
16         %b = alloca [68 x i8], align 16         ; <[68 x i8]*> [#uses=6]
17         "alloca point" = bitcast i32 0 to i32           ; <i32> [#uses=0]
18         store i32 %count, i32* %count_addr
19         store i32 0, i32* %c
20         %b1 = bitcast [68 x i8]* %b to i8*              ; <i8*> [#uses=1]
21         %tmp2 = getelementptr [68 x i8]* @str, i32 0, i32 0             ; <i8*> [#uses=1]
22         call void @llvm.memcpy.i32( i8* %b1, i8* %tmp2, i32 68, i32 1 )
23         store i32 0, i32* %j
24         br label %bb41
25
26 bb:             ; preds = %bb41
27         store i32 0, i32* %i
28         %tmp3 = load i32* %i            ; <i32> [#uses=1]
29         store i32 %tmp3, i32* %c
30         br label %bb36
31
32 bb4:            ; preds = %bb36
33         %b5 = bitcast [68 x i8]* %b to i8*              ; <i8*> [#uses=1]
34         %tmp6 = getelementptr [5 x i8]* @str1, i32 0, i32 0             ; <i8*> [#uses=1]
35         %tmp7 = call i8* @strstr( i8* %b5, i8* %tmp6 )          ; <i8*> [#uses=1]
36         store i8* %tmp7, i8** %p
37         %tmp8 = load i8** %p            ; <i8*> [#uses=1]
38         %ttmp8 = icmp ne i8* %tmp8, null                ; <i1>:0 [#uses=1]
39         %ttmp10 = zext i1 %ttmp8 to i8          ; <i8>:1 [#uses=1]
40         %ttmp7 = icmp ne i8 %ttmp10, 0          ; <i1>:2 [#uses=1]
41         br i1 %ttmp7, label %cond_true, label %cond_next
42
43 cond_true:              ; preds = %bb4
44         %tmp9 = load i8** %p            ; <i8*> [#uses=1]
45         %tmp910 = ptrtoint i8* %tmp9 to i32             ; <i32> [#uses=1]
46         %b11 = bitcast [68 x i8]* %b to i8*             ; <i8*> [#uses=1]
47         %b1112 = ptrtoint i8* %b11 to i32               ; <i32> [#uses=1]
48         %tmp13 = sub i32 %tmp910, %b1112                ; <i32> [#uses=1]
49         %tmp14 = load i32* %c           ; <i32> [#uses=1]
50         %tmp15 = add i32 %tmp13, %tmp14         ; <i32> [#uses=1]
51         store i32 %tmp15, i32* %c
52         br label %cond_next
53
54 cond_next:              ; preds = %cond_true, %bb4
55         %b16 = bitcast [68 x i8]* %b to i8*             ; <i8*> [#uses=1]
56         %tmp17 = getelementptr [6 x i8]* @str2, i32 0, i32 0            ; <i8*> [#uses=1]
57         %tmp18 = call i8* @strstr( i8* %b16, i8* %tmp17 )               ; <i8*> [#uses=1]
58         store i8* %tmp18, i8** %p
59         %tmp19 = load i8** %p           ; <i8*> [#uses=1]
60         %ttmp6 = icmp ne i8* %tmp19, null               ; <i1>:3 [#uses=1]
61         %ttmp9 = zext i1 %ttmp6 to i8           ; <i8>:4 [#uses=1]
62         %ttmp4 = icmp ne i8 %ttmp9, 0           ; <i1>:5 [#uses=1]
63         br i1 %ttmp4, label %cond_true20, label %cond_next28
64
65 cond_true20:            ; preds = %cond_next
66         %tmp21 = load i8** %p           ; <i8*> [#uses=1]
67         %tmp2122 = ptrtoint i8* %tmp21 to i32           ; <i32> [#uses=1]
68         %b23 = bitcast [68 x i8]* %b to i8*             ; <i8*> [#uses=1]
69         %b2324 = ptrtoint i8* %b23 to i32               ; <i32> [#uses=1]
70         %tmp25 = sub i32 %tmp2122, %b2324               ; <i32> [#uses=1]
71         %tmp26 = load i32* %c           ; <i32> [#uses=1]
72         %tmp27 = add i32 %tmp25, %tmp26         ; <i32> [#uses=1]
73         store i32 %tmp27, i32* %c
74         br label %cond_next28
75
76 cond_next28:            ; preds = %cond_true20, %cond_next
77         %b29 = bitcast [68 x i8]* %b to i8*             ; <i8*> [#uses=1]
78         %tmp30 = getelementptr [3 x i8]* @str3, i32 0, i32 0            ; <i8*> [#uses=1]
79         %tmp31 = call i32 @strcspn( i8* %b29, i8* %tmp30 )              ; <i32> [#uses=1]
80         %tmp32 = load i32* %c           ; <i32> [#uses=1]
81         %tmp33 = add i32 %tmp31, %tmp32         ; <i32> [#uses=1]
82         store i32 %tmp33, i32* %c
83         %tmp34 = load i32* %i           ; <i32> [#uses=1]
84         %tmp35 = add i32 %tmp34, 1              ; <i32> [#uses=1]
85         store i32 %tmp35, i32* %i
86         br label %bb36
87
88 bb36:           ; preds = %cond_next28, %bb
89         %tmp37 = load i32* %i           ; <i32> [#uses=1]
90         %ttmp3= icmp sle i32 %tmp37, 249                ; <i1>:6 [#uses=1]
91         %ttmp12 = zext i1 %ttmp3 to i8          ; <i8>:7 [#uses=1]
92         %ttmp1 = icmp ne i8 %ttmp12, 0          ; <i1>:8 [#uses=1]
93         br i1 %ttmp1, label %bb4, label %bb38
94
95 bb38:           ; preds = %bb36
96         %tmp39 = load i32* %j           ; <i32> [#uses=1]
97         %tmp40 = add i32 %tmp39, 1              ; <i32> [#uses=1]
98         store i32 %tmp40, i32* %j
99         br label %bb41
100
101 bb41:           ; preds = %bb38, %entry
102         %tmp42 = load i32* %j           ; <i32> [#uses=1]
103         %tmp43 = load i32* %count_addr          ; <i32> [#uses=1]
104         %ttmp2 = icmp slt i32 %tmp42, %tmp43            ; <i1>:9 [#uses=1]
105         %ttmp11 = zext i1 %ttmp2 to i8          ; <i8>:10 [#uses=1]
106         %ttmp5 = icmp ne i8 %ttmp11, 0          ; <i1>:11 [#uses=1]
107         br i1 %ttmp5, label %bb, label %bb44
108
109 bb44:           ; preds = %bb41
110         %tmp45 = load i32* %c           ; <i32> [#uses=1]
111         store i32 %tmp45, i32* %tmp
112         %tmp46 = load i32* %tmp         ; <i32> [#uses=1]
113         store i32 %tmp46, i32* %retval
114         br label %return
115
116 return:         ; preds = %bb44
117         %retval47 = load i32* %retval           ; <i32> [#uses=1]
118         ret i32 %retval47
119 }
120
121 declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
122
123 declare i8* @strstr(i8*, i8*)
124
125 declare i32 @strcspn(i8*, i8*)