1 ; RUN: opt -instsimplify -S < %s | FileCheck %s
4 ; Make sure that we correctly fold a fused multiply-add where operands
5 ; are all finite constants and addend is zero.
7 declare double @llvm.fma.f64(double, double, double)
10 define double @PR20832() {
11 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0.0)
14 ; CHECK-LABEL: @PR20832(
15 ; CHECK: ret double 5.600000e+01
17 ; Test builtin fma with all finite non-zero constants.
18 define double @test_all_finite() {
19 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 5.0)
22 ; CHECK-LABEL: @test_all_finite(
23 ; CHECK: ret double 6.100000e+01
25 ; Test builtin fma with a +/-NaN addend.
26 define double @test_NaN_addend() {
27 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF8000000000000)
30 ; CHECK-LABEL: @test_NaN_addend(
31 ; CHECK: ret double 0x7FF8000000000000
33 define double @test_NaN_addend_2() {
34 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF8000000000000)
37 ; CHECK-LABEL: @test_NaN_addend_2(
38 ; CHECK: ret double 0xFFF8000000000000
40 ; Test builtin fma with a +/-Inf addend.
41 define double @test_Inf_addend() {
42 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF0000000000000)
45 ; CHECK-LABEL: @test_Inf_addend(
46 ; CHECK: ret double 0x7FF0000000000000
48 define double @test_Inf_addend_2() {
49 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF0000000000000)
52 ; CHECK-LABEL: @test_Inf_addend_2(
53 ; CHECK: ret double 0xFFF0000000000000
55 ; Test builtin fma with one of the operands to the multiply being +/-NaN.
56 define double @test_NaN_1() {
57 %1 = call double @llvm.fma.f64(double 0x7FF8000000000000, double 8.0, double 0.0)
60 ; CHECK-LABEL: @test_NaN_1(
61 ; CHECK: ret double 0x7FF8000000000000
64 define double @test_NaN_2() {
65 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF8000000000000, double 0.0)
68 ; CHECK-LABEL: @test_NaN_2(
69 ; CHECK: ret double 0x7FF8000000000000
72 define double @test_NaN_3() {
73 %1 = call double @llvm.fma.f64(double 0xFFF8000000000000, double 8.0, double 0.0)
76 ; CHECK-LABEL: @test_NaN_3(
77 ; CHECK: ret double 0x7FF8000000000000
80 define double @test_NaN_4() {
81 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF8000000000000, double 0.0)
84 ; CHECK-LABEL: @test_NaN_4(
85 ; CHECK: ret double 0x7FF8000000000000
88 ; Test builtin fma with one of the operands to the multiply being +/-Inf.
89 define double @test_Inf_1() {
90 %1 = call double @llvm.fma.f64(double 0x7FF0000000000000, double 8.0, double 0.0)
93 ; CHECK-LABEL: @test_Inf_1(
94 ; CHECK: ret double 0x7FF0000000000000
97 define double @test_Inf_2() {
98 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF0000000000000, double 0.0)
101 ; CHECK-LABEL: @test_Inf_2(
102 ; CHECK: ret double 0x7FF0000000000000
105 define double @test_Inf_3() {
106 %1 = call double @llvm.fma.f64(double 0xFFF0000000000000, double 8.0, double 0.0)
109 ; CHECK-LABEL: @test_Inf_3(
110 ; CHECK: ret double 0xFFF0000000000000
113 define double @test_Inf_4() {
114 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF0000000000000, double 0.0)
117 ; CHECK-LABEL: @test_Inf_4(
118 ; CHECK: ret double 0xFFF0000000000000