1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8)
5 declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8)
6 declare {i8, i1} @llvm.umul.with.overflow.i8(i8, i8)
8 declare {i8, i1} @llvm.sadd.with.overflow.i8(i8, i8)
9 declare {i8, i1} @llvm.ssub.with.overflow.i8(i8, i8)
10 declare {i8, i1} @llvm.smul.with.overflow.i8(i8, i8)
12 ;;-----------------------------
14 ;;-----------------------------
16 define {i8, i1} @uadd_1() nounwind {
17 ; CHECK-LABEL: @uadd_1(
18 ; CHECK-NEXT: ret { i8, i1 } { i8 -114, i1 false }
20 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 42, i8 100)
24 define {i8, i1} @uadd_2() nounwind {
25 ; CHECK-LABEL: @uadd_2(
26 ; CHECK-NEXT: ret { i8, i1 } { i8 6, i1 true }
28 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 120)
32 define {i8, i1} @uadd_undef() nounwind {
33 ; CHECK-LABEL: @uadd_undef(
34 ; CHECK-NEXT: ret { i8, i1 } { i8 -1, i1 false }
36 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 undef)
40 ;;-----------------------------
42 ;;-----------------------------
44 define {i8, i1} @usub_1() nounwind {
45 ; CHECK-LABEL: @usub_1(
46 ; CHECK-NEXT: ret { i8, i1 } { i8 2, i1 false }
48 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 2)
52 define {i8, i1} @usub_2() nounwind {
53 ; CHECK-LABEL: @usub_2(
54 ; CHECK-NEXT: ret { i8, i1 } { i8 -2, i1 true }
56 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 6)
60 define {i8, i1} @usub_undef() nounwind {
61 ; CHECK-LABEL: @usub_undef(
62 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
64 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 undef)
68 ;;-----------------------------
70 ;;-----------------------------
72 define {i8, i1} @umul_1() nounwind {
73 ; CHECK-LABEL: @umul_1(
74 ; CHECK-NEXT: ret { i8, i1 } { i8 44, i1 true }
76 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 3)
80 define {i8, i1} @umul_2() nounwind {
81 ; CHECK-LABEL: @umul_2(
82 ; CHECK-NEXT: ret { i8, i1 } { i8 -56, i1 false }
84 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 2)
88 define {i8, i1} @umul_undef() nounwind {
89 ; CHECK-LABEL: @umul_undef(
90 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
92 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 2)
96 define {i8, i1} @umul_both_undef() nounwind {
97 ; CHECK-LABEL: @umul_both_undef(
98 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
100 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 undef)
104 ;;-----------------------------
106 ;;-----------------------------
108 define {i8, i1} @sadd_1() nounwind {
109 ; CHECK-LABEL: @sadd_1(
110 ; CHECK-NEXT: ret { i8, i1 } { i8 44, i1 false }
112 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 42, i8 2)
116 define {i8, i1} @sadd_2() nounwind {
117 ; CHECK-LABEL: @sadd_2(
118 ; CHECK-NEXT: ret { i8, i1 } { i8 -126, i1 true }
120 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 120, i8 10)
124 define {i8, i1} @sadd_3() nounwind {
125 ; CHECK-LABEL: @sadd_3(
126 ; CHECK-NEXT: ret { i8, i1 } { i8 -110, i1 false }
128 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 10)
132 define {i8, i1} @sadd_4() nounwind {
133 ; CHECK-LABEL: @sadd_4(
134 ; CHECK-NEXT: ret { i8, i1 } { i8 126, i1 true }
136 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 -10)
140 define {i8, i1} @sadd_5() nounwind {
141 ; CHECK-LABEL: @sadd_5(
142 ; CHECK-NEXT: ret { i8, i1 } { i8 -8, i1 false }
144 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 2, i8 -10)
148 define {i8, i1} @sadd_undef() nounwind {
149 ; CHECK-LABEL: @sadd_undef(
150 ; CHECK-NEXT: ret { i8, i1 } { i8 -1, i1 false }
152 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 undef, i8 -10)
156 ;;-----------------------------
158 ;;-----------------------------
160 define {i8, i1} @ssub_1() nounwind {
161 ; CHECK-LABEL: @ssub_1(
162 ; CHECK-NEXT: ret { i8, i1 } { i8 2, i1 false }
164 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 2)
168 define {i8, i1} @ssub_2() nounwind {
169 ; CHECK-LABEL: @ssub_2(
170 ; CHECK-NEXT: ret { i8, i1 } { i8 -2, i1 false }
172 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 6)
176 define {i8, i1} @ssub_3() nounwind {
177 ; CHECK-LABEL: @ssub_3(
178 ; CHECK-NEXT: ret { i8, i1 } { i8 126, i1 true }
180 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 120)
184 define {i8, i1} @ssub_3b() nounwind {
185 ; CHECK-LABEL: @ssub_3b(
186 ; CHECK-NEXT: ret { i8, i1 } { i8 -20, i1 false }
188 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 10)
192 define {i8, i1} @ssub_4() nounwind {
193 ; CHECK-LABEL: @ssub_4(
194 ; CHECK-NEXT: ret { i8, i1 } { i8 -126, i1 true }
196 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 120, i8 -10)
200 define {i8, i1} @ssub_4b() nounwind {
201 ; CHECK-LABEL: @ssub_4b(
202 ; CHECK-NEXT: ret { i8, i1 } { i8 30, i1 false }
204 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 20, i8 -10)
208 define {i8, i1} @ssub_5() nounwind {
209 ; CHECK-LABEL: @ssub_5(
210 ; CHECK-NEXT: ret { i8, i1 } { i8 -10, i1 false }
212 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -20, i8 -10)
216 define {i8, i1} @ssub_undef() nounwind {
217 ; CHECK-LABEL: @ssub_undef(
218 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
220 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 undef, i8 -10)
224 ;;-----------------------------
226 ;;-----------------------------
228 define {i8, i1} @smul_1() nounwind {
229 ; CHECK-LABEL: @smul_1(
230 ; CHECK-NEXT: ret { i8, i1 } { i8 -56, i1 true }
232 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 -10)
236 define {i8, i1} @smul_undef() nounwind {
237 ; CHECK-LABEL: @smul_undef(
238 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
240 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 undef)
244 define {i8, i1} @smul_both_undef() nounwind {
245 ; CHECK-LABEL: @smul_both_undef(
246 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
248 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 undef, i8 undef)