1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
5 ; Make sure that we correctly fold a fused multiply-add where operands
6 ; are all finite constants and addend is zero.
8 declare double @llvm.fma.f64(double, double, double)
11 define double @PR20832() {
12 ; CHECK-LABEL: @PR20832(
13 ; CHECK-NEXT: ret double 5.600000e+01
15 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0.0)
19 ; Test builtin fma with all finite non-zero constants.
20 define double @test_all_finite() {
21 ; CHECK-LABEL: @test_all_finite(
22 ; CHECK-NEXT: ret double 6.100000e+01
24 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 5.0)
28 ; Test builtin fma with a +/-NaN addend.
29 define double @test_NaN_addend() {
30 ; CHECK-LABEL: @test_NaN_addend(
31 ; CHECK-NEXT: ret double 0x7FF8000000000000
33 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF8000000000000)
37 define double @test_NaN_addend_2() {
38 ; CHECK-LABEL: @test_NaN_addend_2(
39 ; CHECK-NEXT: ret double 0xFFF8000000000000
41 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF8000000000000)
45 ; Test builtin fma with a +/-Inf addend.
46 define double @test_Inf_addend() {
47 ; CHECK-LABEL: @test_Inf_addend(
48 ; CHECK-NEXT: ret double 0x7FF0000000000000
50 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF0000000000000)
54 define double @test_Inf_addend_2() {
55 ; CHECK-LABEL: @test_Inf_addend_2(
56 ; CHECK-NEXT: ret double 0xFFF0000000000000
58 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF0000000000000)
62 ; Test builtin fma with one of the operands to the multiply being +/-NaN.
63 define double @test_NaN_1() {
64 ; CHECK-LABEL: @test_NaN_1(
65 ; CHECK-NEXT: ret double 0x7FF8000000000000
67 %1 = call double @llvm.fma.f64(double 0x7FF8000000000000, double 8.0, double 0.0)
71 define double @test_NaN_2() {
72 ; CHECK-LABEL: @test_NaN_2(
73 ; CHECK-NEXT: ret double 0x7FF8000000000000
75 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF8000000000000, double 0.0)
79 define double @test_NaN_3() {
80 ; CHECK-LABEL: @test_NaN_3(
81 ; CHECK-NEXT: ret double 0xFFF8000000000000
83 %1 = call double @llvm.fma.f64(double 0xFFF8000000000000, double 8.0, double 0.0)
87 define double @test_NaN_4() {
88 ; CHECK-LABEL: @test_NaN_4(
89 ; CHECK-NEXT: ret double 0xFFF8000000000000
91 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF8000000000000, double 0.0)
95 ; Test builtin fma with one of the operands to the multiply being +/-Inf.
96 define double @test_Inf_1() {
97 ; CHECK-LABEL: @test_Inf_1(
98 ; CHECK-NEXT: ret double 0x7FF0000000000000
100 %1 = call double @llvm.fma.f64(double 0x7FF0000000000000, double 8.0, double 0.0)
104 define double @test_Inf_2() {
105 ; CHECK-LABEL: @test_Inf_2(
106 ; CHECK-NEXT: ret double 0x7FF0000000000000
108 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF0000000000000, double 0.0)
112 define double @test_Inf_3() {
113 ; CHECK-LABEL: @test_Inf_3(
114 ; CHECK-NEXT: ret double 0xFFF0000000000000
116 %1 = call double @llvm.fma.f64(double 0xFFF0000000000000, double 8.0, double 0.0)
120 define double @test_Inf_4() {
121 ; CHECK-LABEL: @test_Inf_4(
122 ; CHECK-NEXT: ret double 0xFFF0000000000000
124 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF0000000000000, double 0.0)
130 define double @inf_product_opposite_inf_addend_1() {
131 ; CHECK-LABEL: @inf_product_opposite_inf_addend_1(
132 ; CHECK-NEXT: ret double 0x7FF8000000000000
134 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF0000000000000, double 0x7FF0000000000000)
140 define double @inf_product_opposite_inf_addend_2() {
141 ; CHECK-LABEL: @inf_product_opposite_inf_addend_2(
142 ; CHECK-NEXT: ret double 0x7FF8000000000000
144 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF0000000000000, double 0xFFF0000000000000)
150 define double @inf_product_opposite_inf_addend_3() {
151 ; CHECK-LABEL: @inf_product_opposite_inf_addend_3(
152 ; CHECK-NEXT: ret double 0x7FF8000000000000
154 %1 = call double @llvm.fma.f64(double 0xFFF0000000000000, double 42.0, double 0x7FF0000000000000)
160 define double @inf_product_opposite_inf_addend_4() {
161 ; CHECK-LABEL: @inf_product_opposite_inf_addend_4(
162 ; CHECK-NEXT: ret double 0x7FF8000000000000
164 %1 = call double @llvm.fma.f64(double 0x7FF0000000000000, double 42.0, double 0xFFF0000000000000)
170 define double @inf_times_zero_1() {
171 ; CHECK-LABEL: @inf_times_zero_1(
172 ; CHECK-NEXT: ret double 0x7FF8000000000000
174 %1 = call double @llvm.fma.f64(double 0.0, double 0xFFF0000000000000, double 42.0)
180 define double @inf_times_zero_2() {
181 ; CHECK-LABEL: @inf_times_zero_2(
182 ; CHECK-NEXT: ret double 0x7FF8000000000000
184 %1 = call double @llvm.fma.f64(double 0.0, double 0x7FF0000000000000, double 42.0)
190 define double @inf_times_zero_3() {
191 ; CHECK-LABEL: @inf_times_zero_3(
192 ; CHECK-NEXT: ret double 0x7FF8000000000000
194 %1 = call double @llvm.fma.f64(double 0xFFF0000000000000, double 0.0, double 42.0)
200 define double @inf_times_zero_4() {
201 ; CHECK-LABEL: @inf_times_zero_4(
202 ; CHECK-NEXT: ret double 0x7FF8000000000000
204 %1 = call double @llvm.fma.f64(double 0x7FF0000000000000, double 0.0, double 42.0)
210 define double @inf_times_zero_5() {
211 ; CHECK-LABEL: @inf_times_zero_5(
212 ; CHECK-NEXT: ret double 0x7FF8000000000000
214 %1 = call double @llvm.fma.f64(double -0.0, double 0xFFF0000000000000, double 42.0)
220 define double @inf_times_zero_6() {
221 ; CHECK-LABEL: @inf_times_zero_6(
222 ; CHECK-NEXT: ret double 0x7FF8000000000000
224 %1 = call double @llvm.fma.f64(double -0.0, double 0x7FF0000000000000, double 42.0)
230 define double @inf_times_zero_7() {
231 ; CHECK-LABEL: @inf_times_zero_7(
232 ; CHECK-NEXT: ret double 0x7FF8000000000000
234 %1 = call double @llvm.fma.f64(double 0xFFF0000000000000, double -0.0, double 42.0)
240 define double @inf_times_zero_8() {
241 ; CHECK-LABEL: @inf_times_zero_8(
242 ; CHECK-NEXT: ret double 0x7FF8000000000000
244 %1 = call double @llvm.fma.f64(double 0x7FF0000000000000, double -0.0, double 42.0)