1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
6 ; CHECK-NEXT: ret i64 undef
8 %r = mul i64 undef, undef
13 ; CHECK-LABEL: @test1(
14 ; CHECK-NEXT: ret i64 undef
21 ; CHECK-LABEL: @test2(
22 ; CHECK-NEXT: ret i64 undef
29 ; CHECK-LABEL: @test3(
30 ; CHECK-NEXT: ret i64 0
37 ; CHECK-LABEL: @test4(
38 ; CHECK-NEXT: ret i64 0
45 ; CHECK-LABEL: @test5(
46 ; CHECK-NEXT: ret i64 undef
48 %r = and i64 undef, undef
53 ; CHECK-LABEL: @test6(
54 ; CHECK-NEXT: ret i64 undef
56 %r = or i64 undef, undef
61 ; CHECK-LABEL: @test7(
62 ; CHECK-NEXT: ret i64 undef
64 %r = udiv i64 undef, 1
69 ; CHECK-LABEL: @test8(
70 ; CHECK-NEXT: ret i64 undef
72 %r = sdiv i64 undef, 1
77 ; CHECK-LABEL: @test9(
78 ; CHECK-NEXT: ret i64 0
80 %r = urem i64 undef, 1
84 define i64 @test10() {
85 ; CHECK-LABEL: @test10(
86 ; CHECK-NEXT: ret i64 0
88 %r = srem i64 undef, 1
92 define i64 @test11() {
93 ; CHECK-LABEL: @test11(
94 ; CHECK-NEXT: ret i64 poison
96 %r = shl i64 undef, undef
100 define i64 @test11b(i64 %a) {
101 ; CHECK-LABEL: @test11b(
102 ; CHECK-NEXT: ret i64 poison
104 %r = shl i64 %a, undef
108 define i64 @test12() {
109 ; CHECK-LABEL: @test12(
110 ; CHECK-NEXT: ret i64 poison
112 %r = ashr i64 undef, undef
116 define i64 @test12b(i64 %a) {
117 ; CHECK-LABEL: @test12b(
118 ; CHECK-NEXT: ret i64 poison
120 %r = ashr i64 %a, undef
124 define i64 @test13() {
125 ; CHECK-LABEL: @test13(
126 ; CHECK-NEXT: ret i64 poison
128 %r = lshr i64 undef, undef
132 define i64 @test13b(i64 %a) {
133 ; CHECK-LABEL: @test13b(
134 ; CHECK-NEXT: ret i64 poison
136 %r = lshr i64 %a, undef
140 define i1 @test14() {
141 ; CHECK-LABEL: @test14(
142 ; CHECK-NEXT: ret i1 undef
144 %r = icmp slt i64 undef, undef
148 define i1 @test15() {
149 ; CHECK-LABEL: @test15(
150 ; CHECK-NEXT: ret i1 undef
152 %r = icmp ult i64 undef, undef
156 define i64 @test16(i64 %a) {
157 ; CHECK-LABEL: @test16(
158 ; CHECK-NEXT: ret i64 undef
160 %r = select i1 undef, i64 %a, i64 undef
164 define i64 @test17(i64 %a) {
165 ; CHECK-LABEL: @test17(
166 ; CHECK-NEXT: ret i64 undef
168 %r = select i1 undef, i64 undef, i64 %a
172 define i64 @test18(i64 %a) {
173 ; CHECK-LABEL: @test18(
174 ; CHECK-NEXT: [[R:%.*]] = call i64 undef(i64 [[A:%.*]])
175 ; CHECK-NEXT: ret i64 poison
177 %r = call i64 (i64) undef(i64 %a)
181 define <4 x i8> @test19(<4 x i8> %a) {
182 ; CHECK-LABEL: @test19(
183 ; CHECK-NEXT: ret <4 x i8> poison
185 %b = shl <4 x i8> %a, <i8 8, i8 9, i8 undef, i8 -1>
189 define i32 @test20(i32 %a) {
190 ; CHECK-LABEL: @test20(
191 ; CHECK-NEXT: ret i32 poison
197 define <2 x i32> @test20vec(<2 x i32> %a) {
198 ; CHECK-LABEL: @test20vec(
199 ; CHECK-NEXT: ret <2 x i32> poison
201 %b = udiv <2 x i32> %a, zeroinitializer
205 define i32 @test21(i32 %a) {
206 ; CHECK-LABEL: @test21(
207 ; CHECK-NEXT: ret i32 poison
213 define <2 x i32> @test21vec(<2 x i32> %a) {
214 ; CHECK-LABEL: @test21vec(
215 ; CHECK-NEXT: ret <2 x i32> poison
217 %b = sdiv <2 x i32> %a, zeroinitializer
221 define i32 @test22(i32 %a) {
222 ; CHECK-LABEL: @test22(
223 ; CHECK-NEXT: ret i32 undef
225 %b = ashr exact i32 undef, %a
229 define i32 @test23(i32 %a) {
230 ; CHECK-LABEL: @test23(
231 ; CHECK-NEXT: ret i32 undef
233 %b = lshr exact i32 undef, %a
237 define i32 @test24() {
238 ; CHECK-LABEL: @test24(
239 ; CHECK-NEXT: ret i32 poison
241 %b = udiv i32 undef, 0
245 define i32 @test25() {
246 ; CHECK-LABEL: @test25(
247 ; CHECK-NEXT: ret i32 poison
249 %b = lshr i32 0, undef
253 define i32 @test26() {
254 ; CHECK-LABEL: @test26(
255 ; CHECK-NEXT: ret i32 poison
257 %b = ashr i32 0, undef
261 define i32 @test27() {
262 ; CHECK-LABEL: @test27(
263 ; CHECK-NEXT: ret i32 poison
265 %b = shl i32 0, undef
269 define i32 @test28(i32 %a) {
270 ; CHECK-LABEL: @test28(
271 ; CHECK-NEXT: ret i32 undef
273 %b = shl nsw i32 undef, %a
277 define i32 @test29(i32 %a) {
278 ; CHECK-LABEL: @test29(
279 ; CHECK-NEXT: ret i32 undef
281 %b = shl nuw i32 undef, %a
285 define i32 @test30(i32 %a) {
286 ; CHECK-LABEL: @test30(
287 ; CHECK-NEXT: ret i32 undef
289 %b = shl nsw nuw i32 undef, %a
293 define i32 @test31(i32 %a) {
294 ; CHECK-LABEL: @test31(
295 ; CHECK-NEXT: ret i32 0
297 %b = shl i32 undef, %a
301 define i32 @test32(i32 %a) {
302 ; CHECK-LABEL: @test32(
303 ; CHECK-NEXT: ret i32 undef
305 %b = shl i32 undef, 0
309 define i32 @test33(i32 %a) {
310 ; CHECK-LABEL: @test33(
311 ; CHECK-NEXT: ret i32 undef
313 %b = ashr i32 undef, 0
317 define i32 @test34(i32 %a) {
318 ; CHECK-LABEL: @test34(
319 ; CHECK-NEXT: ret i32 undef
321 %b = lshr i32 undef, 0
325 define i32 @test35(<4 x i32> %V) {
326 ; CHECK-LABEL: @test35(
327 ; CHECK-NEXT: ret i32 poison
329 %b = extractelement <4 x i32> %V, i32 4
333 define i32 @test36(i32 %V) {
334 ; CHECK-LABEL: @test36(
335 ; CHECK-NEXT: ret i32 undef
337 %b = extractelement <4 x i32> undef, i32 %V
341 define i32 @test37() {
342 ; CHECK-LABEL: @test37(
343 ; CHECK-NEXT: ret i32 poison
345 %b = udiv i32 undef, undef
349 define i32 @test38(i32 %a) {
350 ; CHECK-LABEL: @test38(
351 ; CHECK-NEXT: ret i32 poison
353 %b = udiv i32 %a, undef
357 define i32 @test39() {
358 ; CHECK-LABEL: @test39(
359 ; CHECK-NEXT: ret i32 poison
361 %b = udiv i32 0, undef