blob: 3a9a6fc5471ac9a0f0c2e2471b51a74591febe32 [file] [log] [blame]
Tim Northovere3d42362013-02-01 11:40:47 +00001; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -fp-contract=fast | FileCheck %s
Stephen Lin73de7bf2013-07-09 18:16:56 +00002; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s -check-prefix=CHECK-NOFAST
Tim Northovere0e3aef2013-01-31 12:12:40 +00003
4declare float @llvm.fma.f32(float, float, float)
5declare double @llvm.fma.f64(double, double, double)
6
7define float @test_fmadd(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +00008; CHECK-LABEL: test_fmadd:
9; CHECK-NOFAST-LABEL: test_fmadd:
Tim Northovere0e3aef2013-01-31 12:12:40 +000010 %val = call float @llvm.fma.f32(float %a, float %b, float %c)
11; CHECK: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000012; CHECK-NOFAST: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000013 ret float %val
14}
15
16define float @test_fmsub(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +000017; CHECK-LABEL: test_fmsub:
18; CHECK-NOFAST-LABEL: test_fmsub:
Tim Northovere0e3aef2013-01-31 12:12:40 +000019 %nega = fsub float -0.0, %a
20 %val = call float @llvm.fma.f32(float %nega, float %b, float %c)
21; CHECK: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000022; CHECK-NOFAST: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000023 ret float %val
24}
25
26define float @test_fnmadd(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +000027; CHECK-LABEL: test_fnmadd:
28; CHECK-NOFAST-LABEL: test_fnmadd:
Tim Northovere0e3aef2013-01-31 12:12:40 +000029 %negc = fsub float -0.0, %c
30 %val = call float @llvm.fma.f32(float %a, float %b, float %negc)
31; CHECK: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000032; CHECK-NOFAST: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000033 ret float %val
34}
35
36define float @test_fnmsub(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +000037; CHECK-LABEL: test_fnmsub:
38; CHECK-NOFAST-LABEL: test_fnmsub:
Tim Northovere0e3aef2013-01-31 12:12:40 +000039 %nega = fsub float -0.0, %a
40 %negc = fsub float -0.0, %c
41 %val = call float @llvm.fma.f32(float %nega, float %b, float %negc)
42; CHECK: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000043; CHECK-NOFAST: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000044 ret float %val
45}
46
47define double @testd_fmadd(double %a, double %b, double %c) {
Stephen Linf799e3f2013-07-13 20:38:47 +000048; CHECK-LABEL: testd_fmadd:
Stephen Lind24ab202013-07-14 06:24:09 +000049; CHECK-NOFAST-LABEL: testd_fmadd:
Tim Northovere0e3aef2013-01-31 12:12:40 +000050 %val = call double @llvm.fma.f64(double %a, double %b, double %c)
51; CHECK: fmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000052; CHECK-NOFAST: fmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000053 ret double %val
54}
55
56define double @testd_fmsub(double %a, double %b, double %c) {
Stephen Linf799e3f2013-07-13 20:38:47 +000057; CHECK-LABEL: testd_fmsub:
Stephen Lind24ab202013-07-14 06:24:09 +000058; CHECK-NOFAST-LABEL: testd_fmsub:
Tim Northovere0e3aef2013-01-31 12:12:40 +000059 %nega = fsub double -0.0, %a
60 %val = call double @llvm.fma.f64(double %nega, double %b, double %c)
61; CHECK: fmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000062; CHECK-NOFAST: fmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000063 ret double %val
64}
65
66define double @testd_fnmadd(double %a, double %b, double %c) {
Stephen Linf799e3f2013-07-13 20:38:47 +000067; CHECK-LABEL: testd_fnmadd:
Stephen Lind24ab202013-07-14 06:24:09 +000068; CHECK-NOFAST-LABEL: testd_fnmadd:
Tim Northovere0e3aef2013-01-31 12:12:40 +000069 %negc = fsub double -0.0, %c
70 %val = call double @llvm.fma.f64(double %a, double %b, double %negc)
71; CHECK: fnmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000072; CHECK-NOFAST: fnmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000073 ret double %val
74}
75
76define double @testd_fnmsub(double %a, double %b, double %c) {
Stephen Linf799e3f2013-07-13 20:38:47 +000077; CHECK-LABEL: testd_fnmsub:
Stephen Lind24ab202013-07-14 06:24:09 +000078; CHECK-NOFAST-LABEL: testd_fnmsub:
Tim Northovere0e3aef2013-01-31 12:12:40 +000079 %nega = fsub double -0.0, %a
80 %negc = fsub double -0.0, %c
81 %val = call double @llvm.fma.f64(double %nega, double %b, double %negc)
82; CHECK: fnmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000083; CHECK-NOFAST: fnmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000084 ret double %val
85}
86
87define float @test_fmadd_unfused(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +000088; CHECK-LABEL: test_fmadd_unfused:
89; CHECK-NOFAST-LABEL: test_fmadd_unfused:
Tim Northovere0e3aef2013-01-31 12:12:40 +000090 %prod = fmul float %b, %c
91 %sum = fadd float %a, %prod
92; CHECK: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +000093; CHECK-NOFAST-NOT: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
94; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
95; CHECK-NOFAST: fadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +000096 ret float %sum
97}
98
99define float @test_fmsub_unfused(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +0000100; CHECK-LABEL: test_fmsub_unfused:
101; CHECK-NOFAST-LABEL: test_fmsub_unfused:
Tim Northovere0e3aef2013-01-31 12:12:40 +0000102 %prod = fmul float %b, %c
103 %diff = fsub float %a, %prod
104; CHECK: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +0000105; CHECK-NOFAST-NOT: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
106; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
107; CHECK-NOFAST: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +0000108 ret float %diff
109}
110
111define float @test_fnmadd_unfused(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +0000112; CHECK-LABEL: test_fnmadd_unfused:
113; CHECK-NOFAST-LABEL: test_fnmadd_unfused:
Tim Northovere0e3aef2013-01-31 12:12:40 +0000114 %nega = fsub float -0.0, %a
115 %prod = fmul float %b, %c
116 %sum = fadd float %nega, %prod
117; CHECK: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +0000118; CHECK-NOFAST-NOT: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
119; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
120; CHECK-NOFAST: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +0000121 ret float %sum
122}
123
124define float @test_fnmsub_unfused(float %a, float %b, float %c) {
Stephen Lin764d8d32013-07-12 14:54:12 +0000125; CHECK-LABEL: test_fnmsub_unfused:
126; CHECK-NOFAST-LABEL: test_fnmsub_unfused:
Tim Northovere0e3aef2013-01-31 12:12:40 +0000127 %nega = fsub float -0.0, %a
128 %prod = fmul float %b, %c
129 %diff = fsub float %nega, %prod
130; CHECK: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Stephen Lin73de7bf2013-07-09 18:16:56 +0000131; CHECK-NOFAST-NOT: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
132; CHECK-NOFAST: fmul {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
133; CHECK-NOFAST: fneg {{s[0-9]+}}, {{s[0-9]+}}
134; CHECK-NOFAST: fsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
Tim Northovere0e3aef2013-01-31 12:12:40 +0000135 ret float %diff
136}