1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -constprop -S | FileCheck %s --check-prefixes=CHECK,CONSTPROP
3 ; RUN: opt < %s -instsimplify -S | FileCheck %s --check-prefixes=CHECK,INSTSIMPLIFY
4 ; We must *NOT* have any check-lines with prefixes other than CHECK here.
5 ; If we do, that means the rules are different between the passes.
7 declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8)
8 declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8)
9 declare {i8, i1} @llvm.umul.with.overflow.i8(i8, i8)
11 declare {i8, i1} @llvm.sadd.with.overflow.i8(i8, i8)
12 declare {i8, i1} @llvm.ssub.with.overflow.i8(i8, i8)
13 declare {i8, i1} @llvm.smul.with.overflow.i8(i8, i8)
15 ;;-----------------------------
17 ;;-----------------------------
19 define {i8, i1} @uadd_1() nounwind {
20 ; CHECK-LABEL: @uadd_1(
21 ; CHECK-NEXT: ret { i8, i1 } { i8 -114, i1 false }
23 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 42, i8 100)
27 define {i8, i1} @uadd_2() nounwind {
28 ; CHECK-LABEL: @uadd_2(
29 ; CHECK-NEXT: ret { i8, i1 } { i8 6, i1 true }
31 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 120)
35 define {i8, i1} @uadd_undef() nounwind {
36 ; CHECK-LABEL: @uadd_undef(
37 ; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false }
39 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 undef)
43 ;;-----------------------------
45 ;;-----------------------------
47 define {i8, i1} @usub_1() nounwind {
48 ; CHECK-LABEL: @usub_1(
49 ; CHECK-NEXT: ret { i8, i1 } { i8 2, i1 false }
51 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 2)
55 define {i8, i1} @usub_2() nounwind {
56 ; CHECK-LABEL: @usub_2(
57 ; CHECK-NEXT: ret { i8, i1 } { i8 -2, i1 true }
59 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 6)
63 define {i8, i1} @usub_undef() nounwind {
64 ; CHECK-LABEL: @usub_undef(
65 ; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false }
67 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 undef)
71 ;;-----------------------------
73 ;;-----------------------------
75 define {i8, i1} @umul_1() nounwind {
76 ; CHECK-LABEL: @umul_1(
77 ; CHECK-NEXT: ret { i8, i1 } { i8 44, i1 true }
79 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 3)
83 define {i8, i1} @umul_2() nounwind {
84 ; CHECK-LABEL: @umul_2(
85 ; CHECK-NEXT: ret { i8, i1 } { i8 -56, i1 false }
87 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 2)
91 define {i8, i1} @umul_undef() nounwind {
92 ; CHECK-LABEL: @umul_undef(
93 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
95 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 2)
99 define {i8, i1} @umul_both_undef() nounwind {
100 ; CHECK-LABEL: @umul_both_undef(
101 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
103 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 undef)
107 ;;-----------------------------
109 ;;-----------------------------
111 define {i8, i1} @sadd_1() nounwind {
112 ; CHECK-LABEL: @sadd_1(
113 ; CHECK-NEXT: ret { i8, i1 } { i8 44, i1 false }
115 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 42, i8 2)
119 define {i8, i1} @sadd_2() nounwind {
120 ; CHECK-LABEL: @sadd_2(
121 ; CHECK-NEXT: ret { i8, i1 } { i8 -126, i1 true }
123 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 120, i8 10)
127 define {i8, i1} @sadd_3() nounwind {
128 ; CHECK-LABEL: @sadd_3(
129 ; CHECK-NEXT: ret { i8, i1 } { i8 -110, i1 false }
131 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 10)
135 define {i8, i1} @sadd_4() nounwind {
136 ; CHECK-LABEL: @sadd_4(
137 ; CHECK-NEXT: ret { i8, i1 } { i8 126, i1 true }
139 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 -10)
143 define {i8, i1} @sadd_5() nounwind {
144 ; CHECK-LABEL: @sadd_5(
145 ; CHECK-NEXT: ret { i8, i1 } { i8 -8, i1 false }
147 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 2, i8 -10)
151 define {i8, i1} @sadd_undef() nounwind {
152 ; CHECK-LABEL: @sadd_undef(
153 ; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false }
155 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 undef, i8 -10)
159 ;;-----------------------------
161 ;;-----------------------------
163 define {i8, i1} @ssub_1() nounwind {
164 ; CHECK-LABEL: @ssub_1(
165 ; CHECK-NEXT: ret { i8, i1 } { i8 2, i1 false }
167 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 2)
171 define {i8, i1} @ssub_2() nounwind {
172 ; CHECK-LABEL: @ssub_2(
173 ; CHECK-NEXT: ret { i8, i1 } { i8 -2, i1 false }
175 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 6)
179 define {i8, i1} @ssub_3() nounwind {
180 ; CHECK-LABEL: @ssub_3(
181 ; CHECK-NEXT: ret { i8, i1 } { i8 126, i1 true }
183 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 120)
187 define {i8, i1} @ssub_3b() nounwind {
188 ; CHECK-LABEL: @ssub_3b(
189 ; CHECK-NEXT: ret { i8, i1 } { i8 -20, i1 false }
191 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 10)
195 define {i8, i1} @ssub_4() nounwind {
196 ; CHECK-LABEL: @ssub_4(
197 ; CHECK-NEXT: ret { i8, i1 } { i8 -126, i1 true }
199 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 120, i8 -10)
203 define {i8, i1} @ssub_4b() nounwind {
204 ; CHECK-LABEL: @ssub_4b(
205 ; CHECK-NEXT: ret { i8, i1 } { i8 30, i1 false }
207 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 20, i8 -10)
211 define {i8, i1} @ssub_5() nounwind {
212 ; CHECK-LABEL: @ssub_5(
213 ; CHECK-NEXT: ret { i8, i1 } { i8 -10, i1 false }
215 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -20, i8 -10)
219 define {i8, i1} @ssub_undef() nounwind {
220 ; CHECK-LABEL: @ssub_undef(
221 ; CHECK-NEXT: ret { i8, i1 } { i8 undef, i1 false }
223 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 undef, i8 -10)
227 ;;-----------------------------
229 ;;-----------------------------
231 define {i8, i1} @smul_1() nounwind {
232 ; CHECK-LABEL: @smul_1(
233 ; CHECK-NEXT: ret { i8, i1 } { i8 -56, i1 true }
235 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 -10)
239 define {i8, i1} @smul_undef() nounwind {
240 ; CHECK-LABEL: @smul_undef(
241 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
243 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 undef)
247 define {i8, i1} @smul_both_undef() nounwind {
248 ; CHECK-LABEL: @smul_both_undef(
249 ; CHECK-NEXT: ret { i8, i1 } zeroinitializer
251 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 undef, i8 undef)