blob: cd8200bdfd2313368ebc57e4470b3b94a4aaf2d7 [file] [log] [blame]
Evandro Menezeseff2bd92016-10-24 16:14:58 +00001; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -mattr=+neon,-use-reciprocal-square-root | FileCheck %s --check-prefix=FAULT
2; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -mattr=+neon,+use-reciprocal-square-root | FileCheck %s
3
4declare float @llvm.sqrt.f32(float) #0
5declare <2 x float> @llvm.sqrt.v2f32(<2 x float>) #0
6declare <4 x float> @llvm.sqrt.v4f32(<4 x float>) #0
7declare <8 x float> @llvm.sqrt.v8f32(<8 x float>) #0
8declare double @llvm.sqrt.f64(double) #0
9declare <2 x double> @llvm.sqrt.v2f64(<2 x double>) #0
10declare <4 x double> @llvm.sqrt.v4f64(<4 x double>) #0
11
12define float @fsqrt(float %a) #0 {
13 %1 = tail call fast float @llvm.sqrt.f32(float %a)
14 ret float %1
15
16; FAULT-LABEL: fsqrt:
17; FAULT-NEXT: BB#0
18; FAULT-NEXT: fsqrt
19
20; CHECK-LABEL: fsqrt:
21; CHECK-NEXT: BB#0
22; CHECK-NEXT: fmov
23; CHECK-NEXT: frsqrte
24}
25
26define <2 x float> @f2sqrt(<2 x float> %a) #0 {
27 %1 = tail call fast <2 x float> @llvm.sqrt.v2f32(<2 x float> %a)
28 ret <2 x float> %1
29
30; FAULT-LABEL: f2sqrt:
31; FAULT-NEXT: BB#0
32; FAULT-NEXT: fsqrt
33
34; CHECK-LABEL: f2sqrt:
35; CHECK-NEXT: BB#0
36; CHECK-NEXT: fmov
37; CHECK-NEXT: mov
38; CHECK-NEXT: frsqrte
39}
40
41define <4 x float> @f4sqrt(<4 x float> %a) #0 {
42 %1 = tail call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
43 ret <4 x float> %1
44
45; FAULT-LABEL: f4sqrt:
46; FAULT-NEXT: BB#0
47; FAULT-NEXT: fsqrt
48
49; CHECK-LABEL: f4sqrt:
50; CHECK-NEXT: BB#0
51; CHECK-NEXT: fmov
52; CHECK-NEXT: mov
53; CHECK-NEXT: frsqrte
54}
55
56define <8 x float> @f8sqrt(<8 x float> %a) #0 {
57 %1 = tail call fast <8 x float> @llvm.sqrt.v8f32(<8 x float> %a)
58 ret <8 x float> %1
59
60; FAULT-LABEL: f8sqrt:
61; FAULT-NEXT: BB#0
62; FAULT-NEXT: fsqrt
63; FAULT-NEXT: fsqrt
64
65; CHECK-LABEL: f8sqrt:
66; CHECK-NEXT: BB#0
67; CHECK-NEXT: fmov
68; CHECK-NEXT: mov
69; CHECK-NEXT: frsqrte
70; CHECK: frsqrte
71}
72
73define double @dsqrt(double %a) #0 {
74 %1 = tail call fast double @llvm.sqrt.f64(double %a)
75 ret double %1
76
77; FAULT-LABEL: dsqrt:
78; FAULT-NEXT: BB#0
79; FAULT-NEXT: fsqrt
80
81; CHECK-LABEL: dsqrt:
82; CHECK-NEXT: BB#0
83; CHECK-NEXT: fmov
84; CHECK-NEXT: frsqrte
85}
86
87define <2 x double> @d2sqrt(<2 x double> %a) #0 {
88 %1 = tail call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> %a)
89 ret <2 x double> %1
90
91; FAULT-LABEL: d2sqrt:
92; FAULT-NEXT: BB#0
93; FAULT-NEXT: fsqrt
94
95; CHECK-LABEL: d2sqrt:
96; CHECK-NEXT: BB#0
97; CHECK-NEXT: fmov
98; CHECK-NEXT: mov
99; CHECK-NEXT: frsqrte
100}
101
102define <4 x double> @d4sqrt(<4 x double> %a) #0 {
103 %1 = tail call fast <4 x double> @llvm.sqrt.v4f64(<4 x double> %a)
104 ret <4 x double> %1
105
106; FAULT-LABEL: d4sqrt:
107; FAULT-NEXT: BB#0
108; FAULT-NEXT: fsqrt
109; FAULT-NEXT: fsqrt
110
111; CHECK-LABEL: d4sqrt:
112; CHECK-NEXT: BB#0
113; CHECK-NEXT: fmov
114; CHECK-NEXT: mov
115; CHECK-NEXT: frsqrte
116; CHECK: frsqrte
117}
118
119define float @frsqrt(float %a) #0 {
120 %1 = tail call fast float @llvm.sqrt.f32(float %a)
121 %2 = fdiv fast float 1.000000e+00, %1
122 ret float %2
123
124; FAULT-LABEL: frsqrt:
125; FAULT-NEXT: BB#0
126; FAULT-NEXT: fsqrt
127
128; CHECK-LABEL: frsqrt:
129; CHECK-NEXT: BB#0
130; CHECK-NEXT: fmov
131; CHECK-NEXT: frsqrte
132}
133
134define <2 x float> @f2rsqrt(<2 x float> %a) #0 {
135 %1 = tail call fast <2 x float> @llvm.sqrt.v2f32(<2 x float> %a)
136 %2 = fdiv fast <2 x float> <float 1.000000e+00, float 1.000000e+00>, %1
137 ret <2 x float> %2
138
139; FAULT-LABEL: f2rsqrt:
140; FAULT-NEXT: BB#0
141; FAULT-NEXT: fsqrt
142
143; CHECK-LABEL: f2rsqrt:
144; CHECK-NEXT: BB#0
145; CHECK-NEXT: fmov
146; CHECK-NEXT: frsqrte
147}
148
149define <4 x float> @f4rsqrt(<4 x float> %a) #0 {
150 %1 = tail call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
151 %2 = fdiv fast <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %1
152 ret <4 x float> %2
153
154; FAULT-LABEL: f4rsqrt:
155; FAULT-NEXT: BB#0
156; FAULT-NEXT: fsqrt
157
158; CHECK-LABEL: f4rsqrt:
159; CHECK-NEXT: BB#0
160; CHECK-NEXT: fmov
161; CHECK-NEXT: frsqrte
162}
163
164define <8 x float> @f8rsqrt(<8 x float> %a) #0 {
165 %1 = tail call fast <8 x float> @llvm.sqrt.v8f32(<8 x float> %a)
166 %2 = fdiv fast <8 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %1
167 ret <8 x float> %2
168
169; FAULT-LABEL: f8rsqrt:
170; FAULT-NEXT: BB#0
171; FAULT-NEXT: fsqrt
172; FAULT-NEXT: fsqrt
173
174; CHECK-LABEL: f8rsqrt:
175; CHECK-NEXT: BB#0
176; CHECK-NEXT: fmov
177; CHECK-NEXT: frsqrte
178; CHECK: frsqrte
179}
180
181define double @drsqrt(double %a) #0 {
182 %1 = tail call fast double @llvm.sqrt.f64(double %a)
183 %2 = fdiv fast double 1.000000e+00, %1
184 ret double %2
185
186; FAULT-LABEL: drsqrt:
187; FAULT-NEXT: BB#0
188; FAULT-NEXT: fsqrt
189
190; CHECK-LABEL: drsqrt:
191; CHECK-NEXT: BB#0
192; CHECK-NEXT: fmov
193; CHECK-NEXT: frsqrte
194}
195
196define <2 x double> @d2rsqrt(<2 x double> %a) #0 {
197 %1 = tail call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> %a)
198 %2 = fdiv fast <2 x double> <double 1.000000e+00, double 1.000000e+00>, %1
199 ret <2 x double> %2
200
201; FAULT-LABEL: d2rsqrt:
202; FAULT-NEXT: BB#0
203; FAULT-NEXT: fsqrt
204
205; CHECK-LABEL: d2rsqrt:
206; CHECK-NEXT: BB#0
207; CHECK-NEXT: fmov
208; CHECK-NEXT: frsqrte
209}
210
211define <4 x double> @d4rsqrt(<4 x double> %a) #0 {
212 %1 = tail call fast <4 x double> @llvm.sqrt.v4f64(<4 x double> %a)
213 %2 = fdiv fast <4 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>, %1
214 ret <4 x double> %2
215
216; FAULT-LABEL: d4rsqrt:
217; FAULT-NEXT: BB#0
218; FAULT-NEXT: fsqrt
219; FAULT-NEXT: fsqrt
220
221; CHECK-LABEL: d4rsqrt:
222; CHECK-NEXT: BB#0
223; CHECK-NEXT: fmov
224; CHECK-NEXT: frsqrte
225; CHECK: frsqrte
226}
227
228attributes #0 = { nounwind "unsafe-fp-math"="true" }