1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 define float @fadd_undef_op0(float %x) {
5 ; CHECK-LABEL: @fadd_undef_op0(
6 ; CHECK-NEXT: ret float 0x7FF8000000000000
8 %r = fadd float undef, %x
12 define float @fadd_poison_op0(float %x) {
13 ; CHECK-LABEL: @fadd_poison_op0(
14 ; CHECK-NEXT: ret float poison
16 %r = fadd float poison, %x
20 define float @fadd_undef_op1(float %x) {
21 ; CHECK-LABEL: @fadd_undef_op1(
22 ; CHECK-NEXT: ret float 0x7FF8000000000000
24 %r = fadd float %x, undef
28 define float @fadd_poison_op1(float %x) {
29 ; CHECK-LABEL: @fadd_poison_op1(
30 ; CHECK-NEXT: ret float poison
32 %r = fadd float %x, poison
36 define float @fsub_undef_op0(float %x) {
37 ; CHECK-LABEL: @fsub_undef_op0(
38 ; CHECK-NEXT: ret float 0x7FF8000000000000
40 %r = fsub float undef, %x
44 define float @fsub_poison_op0(float %x) {
45 ; CHECK-LABEL: @fsub_poison_op0(
46 ; CHECK-NEXT: ret float poison
48 %r = fsub float poison, %x
52 define float @fsub_undef_op1(float %x) {
53 ; CHECK-LABEL: @fsub_undef_op1(
54 ; CHECK-NEXT: ret float 0x7FF8000000000000
56 %r = fsub float %x, undef
60 define float @fsub_poison_op1(float %x) {
61 ; CHECK-LABEL: @fsub_poison_op1(
62 ; CHECK-NEXT: ret float poison
64 %r = fsub float %x, poison
68 define float @fmul_undef_op0(float %x) {
69 ; CHECK-LABEL: @fmul_undef_op0(
70 ; CHECK-NEXT: ret float 0x7FF8000000000000
72 %r = fmul float undef, %x
76 define float @fmul_poison_op0(float %x) {
77 ; CHECK-LABEL: @fmul_poison_op0(
78 ; CHECK-NEXT: ret float poison
80 %r = fmul float poison, %x
84 define float @fmul_undef_op1(float %x) {
85 ; CHECK-LABEL: @fmul_undef_op1(
86 ; CHECK-NEXT: ret float 0x7FF8000000000000
88 %r = fmul float %x, undef
92 define float @fmul_poison_op1(float %x) {
93 ; CHECK-LABEL: @fmul_poison_op1(
94 ; CHECK-NEXT: ret float poison
96 %r = fmul float %x, poison
100 define float @fdiv_undef_op0(float %x) {
101 ; CHECK-LABEL: @fdiv_undef_op0(
102 ; CHECK-NEXT: ret float 0x7FF8000000000000
104 %r = fdiv float undef, %x
108 define float @fdiv_poison_op0(float %x) {
109 ; CHECK-LABEL: @fdiv_poison_op0(
110 ; CHECK-NEXT: ret float poison
112 %r = fdiv float poison, %x
116 define float @fdiv_undef_op1(float %x) {
117 ; CHECK-LABEL: @fdiv_undef_op1(
118 ; CHECK-NEXT: ret float 0x7FF8000000000000
120 %r = fdiv float %x, undef
124 define float @fdiv_poison_op1(float %x) {
125 ; CHECK-LABEL: @fdiv_poison_op1(
126 ; CHECK-NEXT: ret float poison
128 %r = fdiv float %x, poison
132 define float @frem_undef_op0(float %x) {
133 ; CHECK-LABEL: @frem_undef_op0(
134 ; CHECK-NEXT: ret float 0x7FF8000000000000
136 %r = frem float undef, %x
140 define float @frem_poison_op0(float %x) {
141 ; CHECK-LABEL: @frem_poison_op0(
142 ; CHECK-NEXT: ret float poison
144 %r = frem float poison, %x
148 define float @frem_undef_op1(float %x) {
149 ; CHECK-LABEL: @frem_undef_op1(
150 ; CHECK-NEXT: ret float 0x7FF8000000000000
152 %r = frem float %x, undef
156 define float @frem_poison_op1(float %x) {
157 ; CHECK-LABEL: @frem_poison_op1(
158 ; CHECK-NEXT: ret float poison
160 %r = frem float %x, poison
164 ; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
166 define float @fadd_undef_op0_nnan(float %x) {
167 ; CHECK-LABEL: @fadd_undef_op0_nnan(
168 ; CHECK-NEXT: ret float poison
170 %r = fadd nnan float undef, %x
174 define float @fadd_undef_op1_fast(float %x) {
175 ; CHECK-LABEL: @fadd_undef_op1_fast(
176 ; CHECK-NEXT: ret float poison
178 %r = fadd fast float %x, undef
182 define float @fsub_undef_op0_fast(float %x) {
183 ; CHECK-LABEL: @fsub_undef_op0_fast(
184 ; CHECK-NEXT: ret float poison
186 %r = fsub fast float undef, %x
190 define float @fsub_undef_op1_nnan(float %x) {
191 ; CHECK-LABEL: @fsub_undef_op1_nnan(
192 ; CHECK-NEXT: ret float poison
194 %r = fsub nnan float %x, undef
198 define float @fmul_undef_op0_nnan(float %x) {
199 ; CHECK-LABEL: @fmul_undef_op0_nnan(
200 ; CHECK-NEXT: ret float poison
202 %r = fmul nnan float undef, %x
206 define float @fmul_undef_op1_fast(float %x) {
207 ; CHECK-LABEL: @fmul_undef_op1_fast(
208 ; CHECK-NEXT: ret float poison
210 %r = fmul fast float %x, undef
214 define float @fdiv_undef_op0_fast(float %x) {
215 ; CHECK-LABEL: @fdiv_undef_op0_fast(
216 ; CHECK-NEXT: ret float poison
218 %r = fdiv fast float undef, %x
222 define float @fdiv_undef_op1_nnan(float %x) {
223 ; CHECK-LABEL: @fdiv_undef_op1_nnan(
224 ; CHECK-NEXT: ret float poison
226 %r = fdiv nnan float %x, undef
230 define float @frem_undef_op0_nnan(float %x) {
231 ; CHECK-LABEL: @frem_undef_op0_nnan(
232 ; CHECK-NEXT: ret float poison
234 %r = frem nnan float undef, %x
238 define float @frem_undef_op1_fast(float %x) {
239 ; CHECK-LABEL: @frem_undef_op1_fast(
240 ; CHECK-NEXT: ret float poison
242 %r = frem fast float %x, undef
246 define double @fdiv_ninf_nan_op0(double %x) {
247 ; CHECK-LABEL: @fdiv_ninf_nan_op0(
248 ; CHECK-NEXT: ret double 0xFFF8000000000000
250 %r = fdiv ninf double 0xfff8000000000000, %x
254 define double @fadd_ninf_nan_op1(double %x) {
255 ; CHECK-LABEL: @fadd_ninf_nan_op1(
256 ; CHECK-NEXT: ret double 0x7FF8000000000000
258 %r = fadd ninf double %x, 0x7ff8000000000000
262 define double @fdiv_ninf_inf_op0(double %x) {
263 ; CHECK-LABEL: @fdiv_ninf_inf_op0(
264 ; CHECK-NEXT: ret double poison
266 %r = fdiv ninf double 0x7ff0000000000000, %x
270 define double @fadd_ninf_inf_op1(double %x) {
271 ; CHECK-LABEL: @fadd_ninf_inf_op1(
272 ; CHECK-NEXT: ret double poison
274 %r = fadd ninf double %x, 0xfff0000000000000
278 define double @fsub_nnan_inf_op0(double %x) {
279 ; CHECK-LABEL: @fsub_nnan_inf_op0(
280 ; CHECK-NEXT: ret double 0x7FF0000000000000
282 %r = fsub nnan double 0x7ff0000000000000, %x
286 ; This can't simplify - the result is infinity, but the sign is unknown.
288 define double @fmul_nnan_inf_op1(double %x) {
289 ; CHECK-LABEL: @fmul_nnan_inf_op1(
290 ; CHECK-NEXT: [[R:%.*]] = fmul nnan double [[X:%.*]], 0xFFF0000000000000
291 ; CHECK-NEXT: ret double [[R]]
293 %r = fmul nnan double %x, 0xfff0000000000000