1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define void @test1(float* %a, float* readnone %a_end, i64* %b.i64) {
7 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult float* [[A:%.*]], [[A_END:%.*]]
8 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
9 ; CHECK: for.body.preheader:
10 ; CHECK-NEXT: [[B:%.*]] = load i64, i64* [[B_I64:%.*]], align 8
11 ; CHECK-NEXT: [[B_PTR:%.*]] = inttoptr i64 [[B]] to float*
12 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
14 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[A]], [[FOR_BODY_PREHEADER]] ]
15 ; CHECK-NEXT: [[B_ADDR_02_PTR:%.*]] = phi float* [ [[ADD:%.*]], [[FOR_BODY]] ], [ [[B_PTR]], [[FOR_BODY_PREHEADER]] ]
16 ; CHECK-NEXT: [[I1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
17 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
18 ; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
19 ; CHECK-NEXT: [[ADD]] = getelementptr inbounds float, float* [[B_ADDR_02_PTR]], i64 1
20 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds float, float* [[A_ADDR_03]], i64 1
21 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult float* [[INCDEC_PTR]], [[A_END]]
22 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
24 ; CHECK-NEXT: ret void
27 %cmp1 = icmp ult float* %a, %a_end
28 br i1 %cmp1, label %for.body.preheader, label %for.end
30 for.body.preheader: ; preds = %entry
31 %b = load i64, i64* %b.i64, align 8
34 for.body: ; preds = %for.body, %for.body.preheader
35 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
36 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
39 %tmp = inttoptr i64 %b.addr.02 to float*
40 %i1 = load float, float* %tmp, align 4
41 %mul.i = fmul float %i1, 4.200000e+01
42 store float %mul.i, float* %a.addr.03, align 4
43 %add = getelementptr inbounds float, float* %tmp, i64 1
44 %add.int = ptrtoint float* %add to i64
45 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
46 %cmp = icmp ult float* %incdec.ptr, %a_end
47 br i1 %cmp, label %for.body, label %for.end
49 for.end: ; preds = %for.body, %entry
53 define void @test1_neg(float* %a, float* readnone %a_end, i64* %b.i64) {
54 ; CHECK-LABEL: @test1_neg(
56 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult float* [[A:%.*]], [[A_END:%.*]]
57 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
58 ; CHECK: for.body.preheader:
59 ; CHECK-NEXT: [[B:%.*]] = load i64, i64* [[B_I64:%.*]], align 8
60 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
62 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[INCDEC_PTR:%.*]], [[BB:%.*]] ], [ [[A]], [[FOR_BODY_PREHEADER]] ]
63 ; CHECK-NEXT: [[B_ADDR_02:%.*]] = phi i64 [ [[ADD_INT:%.*]], [[BB]] ], [ [[B]], [[FOR_BODY_PREHEADER]] ]
64 ; CHECK-NEXT: [[TMP:%.*]] = inttoptr i64 [[B_ADDR_02]] to float*
65 ; CHECK-NEXT: [[PTRCMP:%.*]] = icmp ult float* [[TMP]], [[A_END]]
66 ; CHECK-NEXT: br i1 [[PTRCMP]], label [[FOR_END]], label [[BB]]
68 ; CHECK-NEXT: [[I1:%.*]] = load float, float* [[A]], align 4
69 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
70 ; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
71 ; CHECK-NEXT: [[ADD:%.*]] = getelementptr inbounds float, float* [[A]], i64 1
72 ; CHECK-NEXT: [[ADD_INT]] = ptrtoint float* [[ADD]] to i64
73 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds float, float* [[A_ADDR_03]], i64 1
74 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult float* [[INCDEC_PTR]], [[A_END]]
75 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
77 ; CHECK-NEXT: ret void
80 %cmp1 = icmp ult float* %a, %a_end
81 br i1 %cmp1, label %for.body.preheader, label %for.end
83 for.body.preheader: ; preds = %entry
84 %b = load i64, i64* %b.i64, align 8
87 for.body: ; preds = %for.body, %for.body.preheader
88 %a.addr.03 = phi float* [ %incdec.ptr, %bb ], [ %a, %for.body.preheader ]
89 %b.addr.02 = phi i64 [ %add.int, %bb ], [ %b, %for.body.preheader ]
92 %tmp = inttoptr i64 %b.addr.02 to float*
93 %ptrcmp = icmp ult float* %tmp, %a_end
94 br i1 %ptrcmp, label %for.end, label %bb
97 %i1 = load float, float* %a, align 4
98 %mul.i = fmul float %i1, 4.200000e+01
99 store float %mul.i, float* %a.addr.03, align 4
100 %add = getelementptr inbounds float, float* %a, i64 1
101 %add.int = ptrtoint float* %add to i64
102 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
103 %cmp = icmp ult float* %incdec.ptr, %a_end
104 br i1 %cmp, label %for.body, label %for.end
106 for.end: ; preds = %for.body, %entry
111 define void @test2(float* %a, float* readnone %a_end, float** %b.float) {
112 ; CHECK-LABEL: @test2(
114 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult float* [[A:%.*]], [[A_END:%.*]]
115 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
116 ; CHECK: for.body.preheader:
117 ; CHECK-NEXT: [[B_I64:%.*]] = bitcast float** [[B_FLOAT:%.*]] to i64*
118 ; CHECK-NEXT: [[B:%.*]] = load i64, i64* [[B_I64]], align 8
119 ; CHECK-NEXT: [[B_PTR:%.*]] = inttoptr i64 [[B]] to float*
120 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
122 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[A]], [[FOR_BODY_PREHEADER]] ]
123 ; CHECK-NEXT: [[B_ADDR_02_PTR:%.*]] = phi float* [ [[ADD:%.*]], [[FOR_BODY]] ], [ [[B_PTR]], [[FOR_BODY_PREHEADER]] ]
124 ; CHECK-NEXT: [[I1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
125 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
126 ; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
127 ; CHECK-NEXT: [[ADD]] = getelementptr inbounds float, float* [[B_ADDR_02_PTR]], i64 1
128 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds float, float* [[A_ADDR_03]], i64 1
129 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult float* [[INCDEC_PTR]], [[A_END]]
130 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
132 ; CHECK-NEXT: ret void
135 %cmp1 = icmp ult float* %a, %a_end
136 br i1 %cmp1, label %for.body.preheader, label %for.end
138 for.body.preheader: ; preds = %entry
139 %b.i64 = bitcast float** %b.float to i64*
140 %b = load i64, i64* %b.i64, align 8
143 for.body: ; preds = %for.body, %for.body.preheader
144 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
145 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
148 %tmp = inttoptr i64 %b.addr.02 to float*
149 %i1 = load float, float* %tmp, align 4
150 %mul.i = fmul float %i1, 4.200000e+01
151 store float %mul.i, float* %a.addr.03, align 4
152 %add = getelementptr inbounds float, float* %tmp, i64 1
153 %add.int = ptrtoint float* %add to i64
154 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
155 %cmp = icmp ult float* %incdec.ptr, %a_end
156 br i1 %cmp, label %for.body, label %for.end
158 for.end: ; preds = %for.body, %entry
163 define void @test3(float* %a, float* readnone %a_end, i8** %b.i8p) {
164 ; CHECK-LABEL: @test3(
166 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult float* [[A:%.*]], [[A_END:%.*]]
167 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
168 ; CHECK: for.body.preheader:
169 ; CHECK-NEXT: [[B_I64:%.*]] = bitcast i8** [[B_I8P:%.*]] to i64*
170 ; CHECK-NEXT: [[B:%.*]] = load i64, i64* [[B_I64]], align 8
171 ; CHECK-NEXT: [[B_PTR:%.*]] = inttoptr i64 [[B]] to float*
172 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
174 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[A]], [[FOR_BODY_PREHEADER]] ]
175 ; CHECK-NEXT: [[B_ADDR_02_PTR:%.*]] = phi float* [ [[ADD:%.*]], [[FOR_BODY]] ], [ [[B_PTR]], [[FOR_BODY_PREHEADER]] ]
176 ; CHECK-NEXT: [[I1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
177 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
178 ; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
179 ; CHECK-NEXT: [[ADD]] = getelementptr inbounds float, float* [[B_ADDR_02_PTR]], i64 1
180 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds float, float* [[A_ADDR_03]], i64 1
181 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult float* [[INCDEC_PTR]], [[A_END]]
182 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
184 ; CHECK-NEXT: ret void
187 %cmp1 = icmp ult float* %a, %a_end
188 br i1 %cmp1, label %for.body.preheader, label %for.end
190 for.body.preheader: ; preds = %entry
191 %b.i64 = bitcast i8** %b.i8p to i64*
192 %b = load i64, i64* %b.i64, align 8
195 for.body: ; preds = %for.body, %for.body.preheader
196 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
197 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
200 %tmp = inttoptr i64 %b.addr.02 to float*
201 %i1 = load float, float* %tmp, align 4
202 %mul.i = fmul float %i1, 4.200000e+01
203 store float %mul.i, float* %a.addr.03, align 4
204 %add = getelementptr inbounds float, float* %tmp, i64 1
205 %add.int = ptrtoint float* %add to i64
206 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
207 %cmp = icmp ult float* %incdec.ptr, %a_end
208 br i1 %cmp, label %for.body, label %for.end
210 for.end: ; preds = %for.body, %entry
215 define void @test4(float* %a, float* readnone %a_end, float** %b.float) {
216 ; CHECK-LABEL: @test4(
218 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult float* [[A:%.*]], [[A_END:%.*]]
219 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
220 ; CHECK: for.body.preheader:
221 ; CHECK-NEXT: [[B_F:%.*]] = load float*, float** [[B_FLOAT:%.*]], align 8
222 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
224 ; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[A]], [[FOR_BODY_PREHEADER]] ]
225 ; CHECK-NEXT: [[B_ADDR_02_IN:%.*]] = phi float* [ [[ADD:%.*]], [[FOR_BODY]] ], [ [[B_F]], [[FOR_BODY_PREHEADER]] ]
226 ; CHECK-NEXT: [[I1:%.*]] = load float, float* [[B_ADDR_02_IN]], align 4
227 ; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
228 ; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
229 ; CHECK-NEXT: [[ADD]] = getelementptr inbounds float, float* [[B_ADDR_02_IN]], i64 1
230 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds float, float* [[A_ADDR_03]], i64 1
231 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult float* [[INCDEC_PTR]], [[A_END]]
232 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END]]
234 ; CHECK-NEXT: ret void
237 %cmp1 = icmp ult float* %a, %a_end
238 br i1 %cmp1, label %for.body.preheader, label %for.end
240 for.body.preheader: ; preds = %entry
241 %b.f = load float*, float** %b.float, align 8
242 %b = ptrtoint float* %b.f to i64
245 for.body: ; preds = %for.body, %for.body.preheader
246 %a.addr.03 = phi float* [ %incdec.ptr, %for.body ], [ %a, %for.body.preheader ]
247 %b.addr.02 = phi i64 [ %add.int, %for.body ], [ %b, %for.body.preheader ]
248 %tmp = inttoptr i64 %b.addr.02 to float*
249 %i1 = load float, float* %tmp, align 4
250 %mul.i = fmul float %i1, 4.200000e+01
251 store float %mul.i, float* %a.addr.03, align 4
252 %add = getelementptr inbounds float, float* %tmp, i64 1
253 %add.int = ptrtoint float* %add to i64
254 %incdec.ptr = getelementptr inbounds float, float* %a.addr.03, i64 1
255 %cmp = icmp ult float* %incdec.ptr, %a_end
256 br i1 %cmp, label %for.body, label %for.end
258 for.end: ; preds = %for.body, %entry