1 ; RUN: llc < %s -mtriple=thumbv7-none-eabi -mcpu=cortex-m3 | FileCheck %s -check-prefix=CHECK -check-prefix=SOFT -check-prefix=NONE
2 ; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m4 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=SP -check-prefix=NO-VMLA
3 ; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m33 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=SP -check-prefix=NO-VMLA
4 ; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m7 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=VFP -check-prefix=FP-ARMv8 -check-prefix=VMLA
5 ; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m7 -mattr=-fp64 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=SP -check-prefix=FP-ARMv8 -check-prefix=VMLA
6 ; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-a7 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=NEON-A7 -check-prefix=VFP4 -check-prefix=NO-VMLA
7 ; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-a57 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=NEON-A57 -check-prefix=FP-ARMv8 -check-prefix=VMLA
9 declare float @llvm.sqrt.f32(float %Val)
10 define float @sqrt_f(float %a) {
11 ; CHECK-LABEL: sqrt_f:
13 ; HARD: vsqrt.f32 s0, s0
14 %1 = call float @llvm.sqrt.f32(float %a)
18 declare float @llvm.powi.f32.i32(float %Val, i32 %power)
19 define float @powi_f(float %a, i32 %b) {
20 ; CHECK-LABEL: powi_f:
23 %1 = call float @llvm.powi.f32.i32(float %a, i32 %b)
27 declare float @llvm.sin.f32(float %Val)
28 define float @sin_f(float %a) {
32 %1 = call float @llvm.sin.f32(float %a)
36 declare float @llvm.cos.f32(float %Val)
37 define float @cos_f(float %a) {
41 %1 = call float @llvm.cos.f32(float %a)
45 declare float @llvm.tan.f32(float %Val)
46 define float @tan_f(float %a) {
50 %1 = call float @llvm.tan.f32(float %a)
54 declare float @llvm.pow.f32(float %Val, float %power)
55 define float @pow_f(float %a, float %b) {
59 %1 = call float @llvm.pow.f32(float %a, float %b)
63 declare float @llvm.exp.f32(float %Val)
64 define float @exp_f(float %a) {
68 %1 = call float @llvm.exp.f32(float %a)
72 declare float @llvm.exp2.f32(float %Val)
73 define float @exp2_f(float %a) {
74 ; CHECK-LABEL: exp2_f:
77 %1 = call float @llvm.exp2.f32(float %a)
81 declare float @llvm.log.f32(float %Val)
82 define float @log_f(float %a) {
86 %1 = call float @llvm.log.f32(float %a)
90 declare float @llvm.log10.f32(float %Val)
91 define float @log10_f(float %a) {
92 ; CHECK-LABEL: log10_f:
95 %1 = call float @llvm.log10.f32(float %a)
99 declare float @llvm.log2.f32(float %Val)
100 define float @log2_f(float %a) {
101 ; CHECK-LABEL: log2_f:
104 %1 = call float @llvm.log2.f32(float %a)
108 declare float @llvm.fma.f32(float %a, float %b, float %c)
109 define float @fma_f(float %a, float %b, float %c) {
110 ; CHECK-LABEL: fma_f:
113 %1 = call float @llvm.fma.f32(float %a, float %b, float %c)
117 declare float @llvm.fabs.f32(float %Val)
118 define float @abs_f(float %a) {
119 ; CHECK-LABEL: abs_f:
120 ; SOFT: bic r0, r0, #-2147483648
122 %1 = call float @llvm.fabs.f32(float %a)
126 declare float @llvm.copysign.f32(float %Mag, float %Sgn)
127 define float @copysign_f(float %a, float %b) {
128 ; CHECK-LABEL: copysign_f:
129 ; NONE: lsrs [[REG:r[0-9]+]], r{{[0-9]+}}, #31
130 ; NONE: bfi r{{[0-9]+}}, [[REG]], #31, #1
131 ; SP: lsrs [[REG:r[0-9]+]], r{{[0-9]+}}, #31
132 ; SP: bfi r{{[0-9]+}}, [[REG]], #31, #1
133 ; VFP: lsrs [[REG:r[0-9]+]], r{{[0-9]+}}, #31
134 ; VFP: bfi r{{[0-9]+}}, [[REG]], #31, #1
136 ; NEON-A7-NEXT: vmov.f32 s2, s1
137 ; NEON-A7-NEXT: @ kill: def $s0 killed $s0 def $d0
138 ; NEON-A7-NEXT: vmov.i32 d16, #0x80000000
139 ; NEON-A7-NEXT: vbit d0, d1, d16
140 ; NEON-A7-NEXT: @ kill: def $s0 killed $s0 killed $d0
141 ; NEON-A7-NEXT: bx lr
143 ; NEON-A57-NEXT: vmov.f32 s2, s1
144 ; NEON-A57-NEXT: vmov.i32 d16, #0x80000000
145 ; NEON-A57-NEXT: @ kill: def $s0 killed $s0 def $d0
146 ; NEON-A57-NEXT: vbit d0, d1, d16
147 ; NEON-A57-NEXT: @ kill: def $s0 killed $s0 killed $d0
148 ; NEON-A57-NEXT: bx lr
149 %1 = call float @llvm.copysign.f32(float %a, float %b)
153 declare float @llvm.floor.f32(float %Val)
154 define float @floor_f(float %a) {
155 ; CHECK-LABEL: floor_f:
158 ; FP-ARMv8: vrintm.f32
159 %1 = call float @llvm.floor.f32(float %a)
163 declare float @llvm.ceil.f32(float %Val)
164 define float @ceil_f(float %a) {
165 ; CHECK-LABEL: ceil_f:
168 ; FP-ARMv8: vrintp.f32
169 %1 = call float @llvm.ceil.f32(float %a)
173 declare float @llvm.trunc.f32(float %Val)
174 define float @trunc_f(float %a) {
175 ; CHECK-LABEL: trunc_f:
178 ; FP-ARMv8: vrintz.f32
179 %1 = call float @llvm.trunc.f32(float %a)
183 declare float @llvm.rint.f32(float %Val)
184 define float @rint_f(float %a) {
185 ; CHECK-LABEL: rint_f:
188 ; FP-ARMv8: vrintx.f32
189 %1 = call float @llvm.rint.f32(float %a)
193 declare float @llvm.nearbyint.f32(float %Val)
194 define float @nearbyint_f(float %a) {
195 ; CHECK-LABEL: nearbyint_f:
196 ; SOFT: bl nearbyintf
198 ; FP-ARMv8: vrintr.f32
199 %1 = call float @llvm.nearbyint.f32(float %a)
203 declare float @llvm.round.f32(float %Val)
204 define float @round_f(float %a) {
205 ; CHECK-LABEL: round_f:
208 ; FP-ARMv8: vrinta.f32
209 %1 = call float @llvm.round.f32(float %a)
213 declare float @llvm.fmuladd.f32(float %a, float %b, float %c)
214 define float @fmuladd_f(float %a, float %b, float %c) {
215 ; CHECK-LABEL: fmuladd_f:
216 ; SOFT: bl __aeabi_fmul
217 ; SOFT: bl __aeabi_fadd
221 %1 = call float @llvm.fmuladd.f32(float %a, float %b, float %c)
225 declare i16 @llvm.convert.to.fp16.f32(float %a)
226 define i16 @f_to_h(float %a) {
227 ; CHECK-LABEL: f_to_h:
228 ; SOFT: bl __aeabi_f2h
229 ; HARD: vcvt{{[bt]}}.f16.f32
230 %1 = call i16 @llvm.convert.to.fp16.f32(float %a)
234 declare float @llvm.convert.from.fp16.f32(i16 %a)
235 define float @h_to_f(i16 %a) {
236 ; CHECK-LABEL: h_to_f:
237 ; SOFT: bl __aeabi_h2f
238 ; HARD: vcvt{{[bt]}}.f32.f16
239 %1 = call float @llvm.convert.from.fp16.f32(i16 %a)