1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
4 define i1 @test1(i32 %n, i32 %d) {
6 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[D:%.*]], [[N:%.*]]
7 ; CHECK-NEXT: ret i1 [[CMP1]]
10 %cmp1 = icmp eq i32 %div, 0
14 define <2 x i1> @test1vec(<2 x i32> %n, <2 x i32> %d) {
15 ; CHECK-LABEL: @test1vec(
16 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[D:%.*]], [[N:%.*]]
17 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
19 %div = udiv <2 x i32> %n, %d
20 %cmp1 = icmp eq <2 x i32> %div, zeroinitializer
24 define i1 @test2(i32 %d) {
25 ; CHECK-LABEL: @test2(
26 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[D:%.*]], 64
27 ; CHECK-NEXT: ret i1 [[CMP1]]
29 %div = udiv i32 64, %d
30 %cmp1 = icmp eq i32 %div, 0
34 define <2 x i1> @test2vec(<2 x i32> %d) {
35 ; CHECK-LABEL: @test2vec(
36 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[D:%.*]], <i32 64, i32 63>
37 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
39 %div = udiv <2 x i32> <i32 64, i32 63>, %d
40 %cmp1 = icmp eq <2 x i32> %div, zeroinitializer
44 define i1 @test3(i32 %n, i32 %d) {
45 ; CHECK-LABEL: @test3(
46 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i32 [[D:%.*]], [[N:%.*]]
47 ; CHECK-NEXT: ret i1 [[CMP1]]
49 %div = udiv i32 %n, %d
50 %cmp1 = icmp ne i32 %div, 0
54 define <2 x i1> @test3vec(<2 x i32> %n, <2 x i32> %d) {
55 ; CHECK-LABEL: @test3vec(
56 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ule <2 x i32> [[D:%.*]], [[N:%.*]]
57 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
59 %div = udiv <2 x i32> %n, %d
60 %cmp1 = icmp ne <2 x i32> %div, zeroinitializer
64 define i1 @test4(i32 %d) {
65 ; CHECK-LABEL: @test4(
66 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[D:%.*]], 65
67 ; CHECK-NEXT: ret i1 [[CMP1]]
69 %div = udiv i32 64, %d
70 %cmp1 = icmp ne i32 %div, 0
74 define <2 x i1> @test4vec(<2 x i32> %d) {
75 ; CHECK-LABEL: @test4vec(
76 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i32> [[D:%.*]], <i32 65, i32 66>
77 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
79 %div = udiv <2 x i32> <i32 64, i32 65>, %d
80 %cmp1 = icmp ne <2 x i32> %div, zeroinitializer
84 define i1 @test5(i32 %d) {
85 ; CHECK-LABEL: @test5(
86 ; CHECK-NEXT: ret i1 true
88 %div = udiv i32 -1, %d
89 %cmp1 = icmp ne i32 %div, 0
93 define <2 x i1> @test5vec(<2 x i32> %d) {
94 ; CHECK-LABEL: @test5vec(
95 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
97 %div = udiv <2 x i32> <i32 -1, i32 -1>, %d
98 %cmp1 = icmp ne <2 x i32> %div, zeroinitializer
102 define i1 @test6(i32 %d) {
103 ; CHECK-LABEL: @test6(
104 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[D:%.*]], 6
105 ; CHECK-NEXT: ret i1 [[CMP1]]
107 %div = udiv i32 5, %d
108 %cmp1 = icmp ugt i32 %div, 0
112 define <2 x i1> @test6vec(<2 x i32> %d) {
113 ; CHECK-LABEL: @test6vec(
114 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i32> [[D:%.*]], <i32 6, i32 6>
115 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
117 %div = udiv <2 x i32> <i32 5, i32 5>, %d
118 %cmp1 = icmp ugt <2 x i32> %div, zeroinitializer
122 ; (icmp ugt (udiv C1, X), C1) -> false.
123 define i1 @test7(i32 %d) {
124 ; CHECK-LABEL: @test7(
125 ; CHECK-NEXT: ret i1 false
127 %div = udiv i32 8, %d
128 %cmp1 = icmp ugt i32 %div, 8
132 define <2 x i1> @test7vec(<2 x i32> %d) {
133 ; CHECK-LABEL: @test7vec(
134 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
136 %div = udiv <2 x i32> <i32 8, i32 8>, %d
137 %cmp1 = icmp ugt <2 x i32> %div, <i32 8, i32 8>
141 define i1 @test8(i32 %d) {
142 ; CHECK-LABEL: @test8(
143 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[D:%.*]], 2
144 ; CHECK-NEXT: ret i1 [[CMP1]]
146 %div = udiv i32 4, %d
147 %cmp1 = icmp ugt i32 %div, 3
151 define <2 x i1> @test8vec(<2 x i32> %d) {
152 ; CHECK-LABEL: @test8vec(
153 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i32> [[D:%.*]], <i32 2, i32 2>
154 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
156 %div = udiv <2 x i32> <i32 4, i32 4>, %d
157 %cmp1 = icmp ugt <2 x i32> %div, <i32 3, i32 3>
161 define i1 @test9(i32 %d) {
162 ; CHECK-LABEL: @test9(
163 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[D:%.*]], 2
164 ; CHECK-NEXT: ret i1 [[CMP1]]
166 %div = udiv i32 4, %d
167 %cmp1 = icmp ugt i32 %div, 2
171 define <2 x i1> @test9vec(<2 x i32> %d) {
172 ; CHECK-LABEL: @test9vec(
173 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i32> [[D:%.*]], <i32 2, i32 2>
174 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
176 %div = udiv <2 x i32> <i32 4, i32 4>, %d
177 %cmp1 = icmp ugt <2 x i32> %div, <i32 2, i32 2>
181 define i1 @test10(i32 %d) {
182 ; CHECK-LABEL: @test10(
183 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[D:%.*]], 3
184 ; CHECK-NEXT: ret i1 [[CMP1]]
186 %div = udiv i32 4, %d
187 %cmp1 = icmp ugt i32 %div, 1
191 define <2 x i1> @test10vec(<2 x i32> %d) {
192 ; CHECK-LABEL: @test10vec(
193 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i32> [[D:%.*]], <i32 3, i32 3>
194 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
196 %div = udiv <2 x i32> <i32 4, i32 4>, %d
197 %cmp1 = icmp ugt <2 x i32> %div, <i32 1, i32 1>
201 define i1 @test11(i32 %d) {
202 ; CHECK-LABEL: @test11(
203 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[D:%.*]], 4
204 ; CHECK-NEXT: ret i1 [[CMP1]]
206 %div = udiv i32 4, %d
207 %cmp1 = icmp ult i32 %div, 1
211 define <2 x i1> @test11vec(<2 x i32> %d) {
212 ; CHECK-LABEL: @test11vec(
213 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[D:%.*]], <i32 4, i32 4>
214 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
216 %div = udiv <2 x i32> <i32 4, i32 4>, %d
217 %cmp1 = icmp ult <2 x i32> %div, <i32 1, i32 1>
221 define i1 @test12(i32 %d) {
222 ; CHECK-LABEL: @test12(
223 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[D:%.*]], 2
224 ; CHECK-NEXT: ret i1 [[CMP1]]
226 %div = udiv i32 4, %d
227 %cmp1 = icmp ult i32 %div, 2
231 define <2 x i1> @test12vec(<2 x i32> %d) {
232 ; CHECK-LABEL: @test12vec(
233 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[D:%.*]], <i32 2, i32 2>
234 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
236 %div = udiv <2 x i32> <i32 4, i32 4>, %d
237 %cmp1 = icmp ult <2 x i32> %div, <i32 2, i32 2>
241 define i1 @test13(i32 %d) {
242 ; CHECK-LABEL: @test13(
243 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[D:%.*]], 1
244 ; CHECK-NEXT: ret i1 [[CMP1]]
246 %div = udiv i32 4, %d
247 %cmp1 = icmp ult i32 %div, 3
251 define <2 x i1> @test13vec(<2 x i32> %d) {
252 ; CHECK-LABEL: @test13vec(
253 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[D:%.*]], <i32 1, i32 1>
254 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
256 %div = udiv <2 x i32> <i32 4, i32 4>, %d
257 %cmp1 = icmp ult <2 x i32> %div, <i32 3, i32 3>
261 define i1 @test14(i32 %d) {
262 ; CHECK-LABEL: @test14(
263 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[D:%.*]], 1
264 ; CHECK-NEXT: ret i1 [[CMP1]]
266 %div = udiv i32 4, %d
267 %cmp1 = icmp ult i32 %div, 4
271 define <2 x i1> @test14vec(<2 x i32> %d) {
272 ; CHECK-LABEL: @test14vec(
273 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[D:%.*]], <i32 1, i32 1>
274 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
276 %div = udiv <2 x i32> <i32 4, i32 4>, %d
277 %cmp1 = icmp ult <2 x i32> %div, <i32 4, i32 4>
281 ; icmp ugt X, UINT_MAX -> false.
282 define i1 @test15(i32 %d) {
283 ; CHECK-LABEL: @test15(
284 ; CHECK-NEXT: ret i1 false
286 %div = udiv i32 4, %d
287 %cmp1 = icmp ugt i32 %div, -1
291 define <2 x i1> @test15vec(<2 x i32> %d) {
292 ; CHECK-LABEL: @test15vec(
293 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
295 %div = udiv <2 x i32> <i32 4, i32 4>, %d
296 %cmp1 = icmp ugt <2 x i32> %div, <i32 -1, i32 -1>
300 ; icmp ult X, UINT_MAX -> true.
301 define i1 @test16(i32 %d) {
302 ; CHECK-LABEL: @test16(
303 ; CHECK-NEXT: ret i1 true
305 %div = udiv i32 4, %d
306 %cmp1 = icmp ult i32 %div, -1
310 define <2 x i1> @test16vec(<2 x i32> %d) {
311 ; CHECK-LABEL: @test16vec(
312 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
314 %div = udiv <2 x i32> <i32 4, i32 4>, %d
315 %cmp1 = icmp ult <2 x i32> %div, <i32 -1, i32 -1>