1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -fp-contract=fast | FileCheck %s
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s -check-prefix=CHECK-NOFAST
3 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=arm64-none-linux-gnu -fp-contract=fast | FileCheck %s
4 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=arm64-apple-ios7.0 | FileCheck %s -check-prefix=CHECK-NOFAST
6 declare float @llvm.fma.f32(float, float, float)
7 declare double @llvm.fma.f64(double, double, double)
9 define float @test_fmadd(float %a, float %b, float %c) {
10 ; CHECK-LABEL: test_fmadd:
11 ; CHECK-NOFAST-LABEL: test_fmadd:
12 %val = call float @llvm.fma.f32(float %a, float %b, float %c)
13 ; CHECK: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
14 ; CHECK-NOFAST: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
18 define float @test_fmsub(float %a, float %b, float %c) {
19 ; CHECK-LABEL: test_fmsub:
20 ; CHECK-NOFAST-LABEL: test_fmsub:
21 %nega = fsub float -0.0, %a
22 %val = call float @llvm.fma.f32(float %nega, float %b, float %c)
23 ; CHECK: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
24 ; CHECK-NOFAST: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
28 define float @test_fnmadd(float %a, float %b, float %c) {
29 ; CHECK-LABEL: test_fnmadd:
30 ; CHECK-NOFAST-LABEL: test_fnmadd:
31 %nega = fsub float -0.0, %a
32 %negc = fsub float -0.0, %c
33 %val = call float @llvm.fma.f32(float %nega, float %b, float %negc)
34 ; CHECK: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
35 ; CHECK-NOFAST: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
39 define float @test_fnmsub(float %a, float %b, float %c) {
40 ; CHECK-LABEL: test_fnmsub:
41 ; CHECK-NOFAST-LABEL: test_fnmsub:
42 %negc = fsub float -0.0, %c
43 %val = call float @llvm.fma.f32(float %a, float %b, float %negc)
44 ; CHECK: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
45 ; CHECK-NOFAST: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
49 define double @testd_fmadd(double %a, double %b, double %c) {
50 ; CHECK-LABEL: testd_fmadd:
51 ; CHECK-NOFAST-LABEL: testd_fmadd:
52 %val = call double @llvm.fma.f64(double %a, double %b, double %c)
53 ; CHECK: fmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
54 ; CHECK-NOFAST: fmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
58 define double @testd_fmsub(double %a, double %b, double %c) {
59 ; CHECK-LABEL: testd_fmsub:
60 ; CHECK-NOFAST-LABEL: testd_fmsub:
61 %nega = fsub double -0.0, %a
62 %val = call double @llvm.fma.f64(double %nega, double %b, double %c)
63 ; CHECK: fmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
64 ; CHECK-NOFAST: fmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
68 define double @testd_fnmadd(double %a, double %b, double %c) {
69 ; CHECK-LABEL: testd_fnmadd:
70 ; CHECK-NOFAST-LABEL: testd_fnmadd:
71 %nega = fsub double -0.0, %a
72 %negc = fsub double -0.0, %c
73 %val = call double @llvm.fma.f64(double %nega, double %b, double %negc)
74 ; CHECK: fnmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
75 ; CHECK-NOFAST: fnmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
79 define double @testd_fnmsub(double %a, double %b, double %c) {
80 ; CHECK-LABEL: testd_fnmsub:
81 ; CHECK-NOFAST-LABEL: testd_fnmsub:
82 %negc = fsub double -0.0, %c
83 %val = call double @llvm.fma.f64(double %a, double %b, double %negc)
84 ; CHECK: fnmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
85 ; CHECK-NOFAST: fnmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
89 define float @test_fmadd_unfused(float %a, float %b, float %c) {
90 ; CHECK-LABEL: test_fmadd_unfused:
91 ; CHECK-NOFAST-LABEL: test_fmadd_unfused:
92 %prod = fmul float %b, %c
93 %sum = fadd float %a, %prod
94 ; CHECK: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
95 ; CHECK-NOFAST-NOT: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
96 ; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
97 ; CHECK-NOFAST: fadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
101 define float @test_fmsub_unfused(float %a, float %b, float %c) {
102 ; CHECK-LABEL: test_fmsub_unfused:
103 ; CHECK-NOFAST-LABEL: test_fmsub_unfused:
104 %prod = fmul float %b, %c
105 %diff = fsub float %a, %prod
106 ; CHECK: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
107 ; CHECK-NOFAST-NOT: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
108 ; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
109 ; CHECK-NOFAST: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
113 define float @test_fnmadd_unfused(float %a, float %b, float %c) {
114 ; CHECK-LABEL: test_fnmadd_unfused:
115 ; CHECK-NOFAST-LABEL: test_fnmadd_unfused:
116 %nega = fsub float -0.0, %a
117 %prod = fmul float %b, %c
118 %diff = fsub float %nega, %prod
119 ; CHECK: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
120 ; CHECK-NOFAST-NOT: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
121 ; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
122 ; CHECK-NOFAST: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
127 define float @test_fnmsub_unfused(float %a, float %b, float %c) {
128 ; CHECK-LABEL: test_fnmsub_unfused:
129 ; CHECK-NOFAST-LABEL: test_fnmsub_unfused:
130 %nega = fsub float -0.0, %a
131 %prod = fmul float %b, %c
132 %sum = fadd float %nega, %prod
133 ; CHECK: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
134 ; CHECK-NOFAST-NOT: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
135 ; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
136 ; CHECK-NOFAST: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
140 ; Another set of tests that check for multiply single use
142 define float @test_fmadd_unfused_su(float %a, float %b, float %c) {
143 ; CHECK-LABEL: test_fmadd_unfused_su:
144 %prod = fmul float %b, %c
145 %sum = fadd float %a, %prod
146 %res = fadd float %sum, %prod
147 ; CHECK-NOT: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
148 ; CHECK: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
149 ; CHECK: fadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
150 ; CHECK: fadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
154 define float @test_fmsub_unfused_su(float %a, float %b, float %c) {
155 ; CHECK-LABEL: test_fmsub_unfused_su:
156 %prod = fmul float %b, %c
157 %diff = fsub float %a, %prod
158 %res = fsub float %diff, %prod
159 ; CHECK-NOT: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
160 ; CHECK: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
161 ; CHECK: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
162 ; CHECK: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}