• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s  -instcombine  -S | FileCheck %s
3
4define void @test1(float* %a, float* readnone %a_end, i64* %b.i64) {
5; CHECK-LABEL: @test1(
6; CHECK-NEXT:  entry:
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:%.*]]
13; CHECK:       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:    [[TMP1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
17; CHECK-NEXT:    [[MUL_I:%.*]] = fmul float [[TMP1]], 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]]
23; CHECK:       for.end:
24; CHECK-NEXT:    ret void
25;
26entry:
27  %cmp1 = icmp ult float* %a, %a_end
28  br i1 %cmp1, label %for.body.preheader, label %for.end
29
30for.body.preheader:                               ; preds = %entry
31  %b = load i64, i64* %b.i64, align 8
32  br label %for.body
33
34for.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 ]
37
38
39  %tmp = inttoptr i64 %b.addr.02 to float*
40  %tmp1 = load float, float* %tmp, align 4
41  %mul.i = fmul float %tmp1, 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
48
49for.end:                                          ; preds = %for.body, %entry
50  ret void
51}
52
53define void @test1_neg(float* %a, float* readnone %a_end, i64* %b.i64) {
54; CHECK-LABEL: @test1_neg(
55; CHECK-NEXT:  entry:
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:%.*]]
61; CHECK:       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]]
67; CHECK:       bb:
68; CHECK-NEXT:    [[TMP1:%.*]] = load float, float* [[A]], align 4
69; CHECK-NEXT:    [[MUL_I:%.*]] = fmul float [[TMP1]], 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]]
76; CHECK:       for.end:
77; CHECK-NEXT:    ret void
78;
79entry:
80  %cmp1 = icmp ult float* %a, %a_end
81  br i1 %cmp1, label %for.body.preheader, label %for.end
82
83for.body.preheader:                               ; preds = %entry
84  %b = load i64, i64* %b.i64, align 8
85  br label %for.body
86
87for.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 ]
90
91
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
95
96bb:
97  %tmp1 = load float, float* %a, align 4
98  %mul.i = fmul float %tmp1, 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
105
106for.end:                                          ; preds = %for.body, %entry
107  ret void
108}
109
110
111define void @test2(float* %a, float* readnone %a_end, float** %b.float) {
112; CHECK-LABEL: @test2(
113; CHECK-NEXT:  entry:
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:%.*]]
121; CHECK:       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:    [[TMP1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
125; CHECK-NEXT:    [[MUL_I:%.*]] = fmul float [[TMP1]], 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]]
131; CHECK:       for.end:
132; CHECK-NEXT:    ret void
133;
134entry:
135  %cmp1 = icmp ult float* %a, %a_end
136  br i1 %cmp1, label %for.body.preheader, label %for.end
137
138for.body.preheader:                               ; preds = %entry
139  %b.i64 = bitcast float** %b.float to i64*
140  %b = load i64, i64* %b.i64, align 8
141  br label %for.body
142
143for.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 ]
146
147
148  %tmp = inttoptr i64 %b.addr.02 to float*
149  %tmp1 = load float, float* %tmp, align 4
150  %mul.i = fmul float %tmp1, 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
157
158for.end:                                          ; preds = %for.body, %entry
159  ret void
160}
161
162
163define void @test3(float* %a, float* readnone %a_end, i8** %b.i8p) {
164; CHECK-LABEL: @test3(
165; CHECK-NEXT:  entry:
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:%.*]]
173; CHECK:       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:    [[TMP1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
177; CHECK-NEXT:    [[MUL_I:%.*]] = fmul float [[TMP1]], 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]]
183; CHECK:       for.end:
184; CHECK-NEXT:    ret void
185;
186entry:
187  %cmp1 = icmp ult float* %a, %a_end
188  br i1 %cmp1, label %for.body.preheader, label %for.end
189
190for.body.preheader:                               ; preds = %entry
191  %b.i64 = bitcast i8** %b.i8p to i64*
192  %b = load i64, i64* %b.i64, align 8
193  br label %for.body
194
195for.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 ]
198
199
200  %tmp = inttoptr i64 %b.addr.02 to float*
201  %tmp1 = load float, float* %tmp, align 4
202  %mul.i = fmul float %tmp1, 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
209
210for.end:                                          ; preds = %for.body, %entry
211  ret void
212}
213
214
215define void @test4(float* %a, float* readnone %a_end, float** %b.float) {
216; CHECK-LABEL: @test4(
217; CHECK-NEXT:  entry:
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:%.*]]
223; CHECK:       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:    [[TMP1:%.*]] = load float, float* [[B_ADDR_02_IN]], align 4
227; CHECK-NEXT:    [[MUL_I:%.*]] = fmul float [[TMP1]], 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]]
233; CHECK:       for.end:
234; CHECK-NEXT:    ret void
235;
236entry:
237  %cmp1 = icmp ult float* %a, %a_end
238  br i1 %cmp1, label %for.body.preheader, label %for.end
239
240for.body.preheader:                               ; preds = %entry
241  %b.f = load float*, float** %b.float, align 8
242  %b = ptrtoint float* %b.f to i64
243  br label %for.body
244
245for.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  %tmp1 = load float, float* %tmp, align 4
250  %mul.i = fmul float %tmp1, 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
257
258for.end:                                          ; preds = %for.body, %entry
259  ret void
260}
261