AArch64/ARM64: add another set of tests from AArch64
[oota-llvm.git] / test / CodeGen / AArch64 / fp-dp3.ll
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
5
6 declare float @llvm.fma.f32(float, float, float)
7 declare double @llvm.fma.f64(double, double, double)
8
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]+}}
15   ret float %val
16 }
17
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]+}}
25   ret float %val
26 }
27
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]+}}
36   ret float %val
37 }
38
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]+}}
46   ret float %val
47 }
48
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]+}}
55   ret double %val
56 }
57
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]+}}
65   ret double %val
66 }
67
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]+}}
76   ret double %val
77 }
78
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]+}}
86   ret double %val
87 }
88
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]+}}
98   ret float %sum
99 }
100
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]+}}
110   ret float %diff
111 }
112
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]+}}
123 ; CHECK-NOFAST: ret
124   ret float %diff
125 }
126
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]+}}
137   ret float %sum
138 }
139
140 ; Another set of tests that check for multiply single use
141
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]+}}
151   ret float %res
152 }
153
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]+}}
163   ret float %res
164 }
165