1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instsimplify -S | FileCheck %s
3
4declare void @use(...)
5
6define void @casts() {
7; CHECK-LABEL: @casts(
8; CHECK-NEXT:    call void (...) @use(i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i32 poison, i8 poison, float poison, float poison, float poison, float poison)
9; CHECK-NEXT:    ret void
10;
11  %i1 = trunc i32 poison to i8
12  %i2 = zext i4 poison to i8
13  %i3 = sext i4 poison to i8
14  %i4 = fptoui float poison to i8
15  %i5 = fptosi float poison to i8
16  %i6 = bitcast float poison to i32
17  %i7 = ptrtoint i8* poison to i8
18  %f1 = fptrunc double poison to float
19  %f2 = fpext half poison to float
20  %f3 = uitofp i8 poison to float
21  %f4 = sitofp i8 poison to float
22  call void (...) @use(i8 %i1, i8 %i2, i8 %i3, i8 %i4, i8 %i5, i32 %i6, i8 %i7, float %f1, float %f2, float %f3, float %f4)
23  ret void
24}
25
26define void @casts2() {
27; CHECK-LABEL: @casts2(
28; CHECK-NEXT:    call void (...) @use(i8* poison, i8* poison)
29; CHECK-NEXT:    ret void
30;
31  %p1 = inttoptr i8 poison to i8*
32  %p2 = addrspacecast i8 addrspace(1)* poison to i8*
33  call void (...) @use(i8* %p1, i8* %p2)
34  ret void
35}
36
37define void @unaryops() {
38; CHECK-LABEL: @unaryops(
39; CHECK-NEXT:    call void (...) @use(float poison)
40; CHECK-NEXT:    ret void
41;
42  %f1 = fneg float poison
43  call void (...) @use(float %f1)
44  ret void
45}
46
47define void @binaryops_arith() {
48; CHECK-LABEL: @binaryops_arith(
49; CHECK-NEXT:    call void (...) @use(i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, float poison, float poison, float poison, float poison, float poison, float poison, float poison)
50; CHECK-NEXT:    ret void
51;
52  %i1 = add i8 poison, 1
53  %i2 = sub i8 poison, 1
54  %i3 = mul i8 poison, 2
55  %i4 = udiv i8 poison, 2
56  %i5 = udiv i8 2, poison
57  %i6 = sdiv i8 poison, 2
58  %i7 = sdiv i8 2, poison
59  %i8 = urem i8 poison, 2
60  %i9 = urem i8 2, poison
61  %i10 = srem i8 poison, 2
62  %i11 = srem i8 2, poison
63  %f1 = fadd float poison, 1.0
64  %f2 = fsub float poison, 1.0
65  %f3 = fmul float poison, 2.0
66  %f4 = fdiv float poison, 2.0
67  %f5 = fdiv float 2.0, poison
68  %f6 = frem float poison, 2.0
69  %f7 = frem float 2.0, poison
70  call void (...) @use(i8 %i1, i8 %i2, i8 %i3, i8 %i4, i8 %i5, i8 %i6, i8 %i7, i8 %i8, i8 %i9, i8 %i10, i8 %i11, float %f1, float %f2, float %f3, float %f4, float %f5, float %f6, float %f7)
71  ret void
72}
73
74define void @binaryops_bitwise() {
75; CHECK-LABEL: @binaryops_bitwise(
76; CHECK-NEXT:    call void (...) @use(i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison)
77; CHECK-NEXT:    ret void
78;
79  %i1 = shl i8 poison, 1
80  %i2 = shl i8 1, poison
81  %i3 = lshr i8 poison, 1
82  %i4 = lshr i8 1, poison
83  %i5 = ashr i8 poison, 1
84  %i6 = ashr i8 1, poison
85  %i7 = and i8 poison, 1
86  %i8 = or i8 poison, 1
87  %i9 = xor i8 poison, 1
88  call void (...) @use(i8 %i1, i8 %i2, i8 %i3, i8 %i4, i8 %i5, i8 %i6, i8 %i7, i8 %i8, i8 %i9)
89  ret void
90}
91
92define void @vec_aggr_ops() {
93; CHECK-LABEL: @vec_aggr_ops(
94; CHECK-NEXT:    call void (...) @use(i8 poison, i8 poison, <2 x i8> poison, i8 poison)
95; CHECK-NEXT:    ret void
96;
97  %i1 = extractelement <2 x i8> poison, i64 0
98  %i2 = extractelement <2 x i8> zeroinitializer, i64 poison
99  %i3 = insertelement <2 x i8> zeroinitializer, i8 0, i64 poison
100  %i4 = extractvalue {i8, i8} poison, 0
101  call void (...) @use(i8 %i1, i8 %i2, <2 x i8> %i3, i8 %i4)
102  ret void
103}
104
105define void @other_ops(i8 %x) {
106; CHECK-LABEL: @other_ops(
107; CHECK-NEXT:    call void (...) @use(i1 poison, i1 poison, i8 poison, i8 poison, i8* poison, i8* poison)
108; CHECK-NEXT:    ret void
109;
110  %i1 = icmp eq i8 poison, 1
111  %i2 = fcmp oeq float poison, 1.0
112  %i3 = select i1 poison, i8 1, i8 2
113  %i4 = select i1 true, i8 poison, i8 %x
114  call void (...) @use(i1 %i1, i1 %i2, i8 %i3, i8 %i4, i8* getelementptr (i8, i8* poison, i64 1), i8* getelementptr inbounds (i8, i8* undef, i64 1))
115  ret void
116}
117
118; TODO: these must be folded into poison; D92270
119define void @logicalops_i1(i1 %x) {
120; CHECK-LABEL: @logicalops_i1(
121; CHECK-NEXT:    call void (...) @use(i1 true, i1 false)
122; CHECK-NEXT:    ret void
123;
124  %i1 = or i1 %x, poison
125  %i2 = and i1 %x, poison
126  call void (...) @use(i1 %i1, i1 %i2)
127  ret void
128}
129