1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define void @test1(float* %a, float* readnone %a_end, i64* %b.i64) {
6 %cmp1 = icmp ult float* %a, %a_end
7 br i1 %cmp1, label %for.body.preheader, label %for.end
9 for.body.preheader: ; preds = %entry
10 %b = load i64, i64* %b.i64, align 8
11 ; CHECK: load float*, float**
14 for.body: ; preds = %for.body, %for.body.preheader
15 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
16 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
18 ; CHECK: %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
19 ; CHECK: %b.addr.02.ptr = phi float* [ %add, %for.body ],
20 ; CHECK-NOT: %b.addr.02 = phi i64
22 %tmp = inttoptr i64 %b.addr.02 to float*
23 ; CHECK-NOT: inttoptr i64
24 %tmp1 = load float, float* %tmp, align 4
26 %mul.i = fmul float %tmp1, 4.200000e+01
27 store float %mul.i, float* %a.addr.03, align 4
28 %add = getelementptr inbounds float, float* %tmp, i64 1
29 %add.int = ptrtoint float* %add to i64
30 ; CHECK %add = getelementptr
31 ; CHECK-NOT: ptrtoint float*
32 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
33 ; CHECK: %incdec.ptr =
34 %cmp = icmp ult float* %incdec.ptr, %a_end
35 br i1 %cmp, label %for.body, label %for.end
37 for.end: ; preds = %for.body, %entry
41 define void @test1_neg(float* %a, float* readnone %a_end, i64* %b.i64) {
42 ; CHECK-LABEL: @test1_neg
44 %cmp1 = icmp ult float* %a, %a_end
45 br i1 %cmp1, label %for.body.preheader, label %for.end
47 for.body.preheader: ; preds = %entry
48 %b = load i64, i64* %b.i64, align 8
51 for.body: ; preds = %for.body, %for.body.preheader
52 %a.addr.03 = phi float* [ %incdec.ptr, %bb ], [ %a, %for.body.preheader ]
53 %b.addr.02 = phi i64 [ %add.int, %bb ], [ %b, %for.body.preheader ]
55 ; CHECK: %a.addr.03 = phi float* [ %incdec.ptr, %bb ], [ %a, %for.body.preheader ]
56 ; CHECK: %b.addr.02 = phi i64
58 %tmp = inttoptr i64 %b.addr.02 to float*
60 %ptrcmp = icmp ult float* %tmp, %a_end
61 br i1 %ptrcmp, label %for.end, label %bb
64 %tmp1 = load float, float* %a, align 4
65 %mul.i = fmul float %tmp1, 4.200000e+01
66 store float %mul.i, float* %a.addr.03, align 4
67 %add = getelementptr inbounds float, float* %a, i64 1
68 %add.int = ptrtoint float* %add to i64
69 ; CHECK: ptrtoint float*
70 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
71 %cmp = icmp ult float* %incdec.ptr, %a_end
72 br i1 %cmp, label %for.body, label %for.end
74 for.end: ; preds = %for.body, %entry
79 define void @test2(float* %a, float* readnone %a_end, float** %b.float) {
82 %cmp1 = icmp ult float* %a, %a_end
83 br i1 %cmp1, label %for.body.preheader, label %for.end
85 for.body.preheader: ; preds = %entry
86 %b.i64 = bitcast float** %b.float to i64*
87 %b = load i64, i64* %b.i64, align 8
88 ; CHECK: load float*, float**
91 for.body: ; preds = %for.body, %for.body.preheader
92 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
93 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
95 ; CHECK: %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
96 ; CHECK: %b.addr.02.ptr = phi float* [ %add, %for.body ],
97 ; CHECK-NOT: %b.addr.02 = phi i64
99 %tmp = inttoptr i64 %b.addr.02 to float*
100 ; CHECK-NOT: inttoptr i64
101 %tmp1 = load float, float* %tmp, align 4
103 %mul.i = fmul float %tmp1, 4.200000e+01
104 store float %mul.i, float* %a.addr.03, align 4
105 %add = getelementptr inbounds float, float* %tmp, i64 1
107 %add.int = ptrtoint float* %add to i64
108 ; CHECK-NOT: ptrtoint float*
109 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
110 ; CHECK: %incdec.ptr =
111 %cmp = icmp ult float* %incdec.ptr, %a_end
112 br i1 %cmp, label %for.body, label %for.end
114 for.end: ; preds = %for.body, %entry
119 define void @test3(float* %a, float* readnone %a_end, i8** %b.i8p) {
120 ; CHECK-LABEL: @test3
122 %cmp1 = icmp ult float* %a, %a_end
123 br i1 %cmp1, label %for.body.preheader, label %for.end
125 for.body.preheader: ; preds = %entry
126 %b.i64 = bitcast i8** %b.i8p to i64*
127 %b = load i64, i64* %b.i64, align 8
128 ; CHECK: load float*, float**
131 for.body: ; preds = %for.body, %for.body.preheader
132 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
133 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
135 ; CHECK: %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
136 ; CHECK: %b.addr.02.ptr = phi float* [ %add, %for.body ],
137 ; CHECK-NOT: %b.addr.02 = phi i64
139 %tmp = inttoptr i64 %b.addr.02 to float*
140 ; CHECK-NOT: inttoptr i64
141 %tmp1 = load float, float* %tmp, align 4
143 %mul.i = fmul float %tmp1, 4.200000e+01
144 store float %mul.i, float* %a.addr.03, align 4
145 %add = getelementptr inbounds float, float* %tmp, i64 1
146 ; CHECK: %add = getelementptr
147 %add.int = ptrtoint float* %add to i64
148 ; CHECK-NOT: ptrtoint float*
149 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
150 ; CHECK: %incdec.ptr =
151 %cmp = icmp ult float* %incdec.ptr, %a_end
152 br i1 %cmp, label %for.body, label %for.end
154 for.end: ; preds = %for.body, %entry
159 define void @test4(float* %a, float* readnone %a_end, float** %b.float) {
161 ; CHECK-LABEL: @test4
162 %cmp1 = icmp ult float* %a, %a_end
163 br i1 %cmp1, label %for.body.preheader, label %for.end
165 for.body.preheader: ; preds = %entry
166 %b.f = load float*, float** %b.float, align 8
167 %b = ptrtoint float* %b.f to i64
168 ; CHECK: load float*, float**
169 ; CHECK-NOT: ptrtoint float*
171 ; CHECK: br label %for.body
173 for.body: ; preds = %for.body, %for.body.preheader
174 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
175 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
176 %tmp = inttoptr i64 %b.addr.02 to float*
177 ; CHECK-NOT: inttoptr i64
178 %tmp1 = load float, float* %tmp, align 4
180 %mul.i = fmul float %tmp1, 4.200000e+01
181 store float %mul.i, float* %a.addr.03, align 4
182 %add = getelementptr inbounds float, float* %tmp, i64 1
184 %add.int = ptrtoint float* %add to i64
185 ; CHECK-NOT: ptrtoint float*
186 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
187 ; CHECK: %incdec.ptr =
188 %cmp = icmp ult float* %incdec.ptr, %a_end
189 br i1 %cmp, label %for.body, label %for.end
191 for.end: ; preds = %for.body, %entry