1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=arm64-eabi < %s | FileCheck %s
4 define float @fma32(float %a, float %b, float %c) nounwind readnone ssp {
6 ; CHECK: // %bb.0: // %entry
7 ; CHECK-NEXT: fmadd s0, s0, s1, s2
10 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c)
14 define float @fnma32(float %a, float %b, float %c) nounwind readnone ssp {
15 ; CHECK-LABEL: fnma32:
16 ; CHECK: // %bb.0: // %entry
17 ; CHECK-NEXT: fnmadd s0, s0, s1, s2
20 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c)
21 %mul = fmul float %0, -1.000000e+00
25 define float @fms32(float %a, float %b, float %c) nounwind readnone ssp {
27 ; CHECK: // %bb.0: // %entry
28 ; CHECK-NEXT: fmsub s0, s0, s1, s2
31 %mul = fmul float %b, -1.000000e+00
32 %0 = tail call float @llvm.fma.f32(float %a, float %mul, float %c)
36 define float @fms32_com(float %a, float %b, float %c) nounwind readnone ssp {
37 ; CHECK-LABEL: fms32_com:
38 ; CHECK: // %bb.0: // %entry
39 ; CHECK-NEXT: fmsub s0, s1, s0, s2
42 %mul = fmul float %b, -1.000000e+00
43 %0 = tail call float @llvm.fma.f32(float %mul, float %a, float %c)
47 define float @fnms32(float %a, float %b, float %c) nounwind readnone ssp {
48 ; CHECK-LABEL: fnms32:
49 ; CHECK: // %bb.0: // %entry
50 ; CHECK-NEXT: fnmsub s0, s0, s1, s2
53 %mul = fmul float %c, -1.000000e+00
54 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %mul)
58 define double @fma64(double %a, double %b, double %c) nounwind readnone ssp {
60 ; CHECK: // %bb.0: // %entry
61 ; CHECK-NEXT: fmadd d0, d0, d1, d2
64 %0 = tail call double @llvm.fma.f64(double %a, double %b, double %c)
68 define double @fnma64(double %a, double %b, double %c) nounwind readnone ssp {
69 ; CHECK-LABEL: fnma64:
70 ; CHECK: // %bb.0: // %entry
71 ; CHECK-NEXT: fnmadd d0, d0, d1, d2
74 %0 = tail call double @llvm.fma.f64(double %a, double %b, double %c)
75 %mul = fmul double %0, -1.000000e+00
79 define double @fms64(double %a, double %b, double %c) nounwind readnone ssp {
81 ; CHECK: // %bb.0: // %entry
82 ; CHECK-NEXT: fmsub d0, d0, d1, d2
86 %0 = tail call double @llvm.fma.f64(double %a, double %mul, double %c)
90 define double @fms64_com(double %a, double %b, double %c) nounwind readnone ssp {
91 ; CHECK-LABEL: fms64_com:
92 ; CHECK: // %bb.0: // %entry
93 ; CHECK-NEXT: fmsub d0, d1, d0, d2
97 %0 = tail call double @llvm.fma.f64(double %mul, double %a, double %c)
101 define double @fnms64(double %a, double %b, double %c) nounwind readnone ssp {
102 ; CHECK-LABEL: fnms64:
103 ; CHECK: // %bb.0: // %entry
104 ; CHECK-NEXT: fnmsub d0, d0, d1, d2
107 %mul = fneg double %c
108 %0 = tail call double @llvm.fma.f64(double %a, double %b, double %mul)
112 define float @fma32_strict(float %a, float %b, float %c) nounwind readnone ssp strictfp {
113 ; CHECK-LABEL: fma32_strict:
114 ; CHECK: // %bb.0: // %entry
115 ; CHECK-NEXT: fmadd s0, s0, s1, s2
118 %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %b, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
122 define float @fnma32_strict(float %a, float %b, float %c) nounwind readnone ssp strictfp {
123 ; CHECK-LABEL: fnma32_strict:
124 ; CHECK: // %bb.0: // %entry
125 ; CHECK-NEXT: fnmadd s0, s0, s1, s2
128 %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %b, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
133 define float @fms32_strict(float %a, float %b, float %c) nounwind readnone ssp strictfp {
134 ; CHECK-LABEL: fms32_strict:
135 ; CHECK: // %bb.0: // %entry
136 ; CHECK-NEXT: fmsub s0, s0, s1, s2
140 %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %neg, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
144 define float @fms32_com_strict(float %a, float %b, float %c) nounwind readnone ssp strictfp {
145 ; CHECK-LABEL: fms32_com_strict:
146 ; CHECK: // %bb.0: // %entry
147 ; CHECK-NEXT: fmsub s0, s0, s1, s2
151 %0 = tail call float @llvm.experimental.constrained.fma.f32(float %neg, float %a, float %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
155 define float @fnms32_strict(float %a, float %b, float %c) nounwind readnone ssp strictfp {
156 ; CHECK-LABEL: fnms32_strict:
157 ; CHECK: // %bb.0: // %entry
158 ; CHECK-NEXT: fnmsub s0, s0, s1, s2
162 %0 = tail call float @llvm.experimental.constrained.fma.f32(float %a, float %b, float %neg, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
166 define double @fma64_strict(double %a, double %b, double %c) nounwind readnone ssp strictfp {
167 ; CHECK-LABEL: fma64_strict:
168 ; CHECK: // %bb.0: // %entry
169 ; CHECK-NEXT: fmadd d0, d0, d1, d2
172 %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %b, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
176 define double @fnma64_strict(double %a, double %b, double %c) nounwind readnone ssp strictfp {
177 ; CHECK-LABEL: fnma64_strict:
178 ; CHECK: // %bb.0: // %entry
179 ; CHECK-NEXT: fnmadd d0, d0, d1, d2
182 %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %b, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
183 %neg = fneg double %0
187 define double @fms64_strict(double %a, double %b, double %c) nounwind readnone ssp strictfp {
188 ; CHECK-LABEL: fms64_strict:
189 ; CHECK: // %bb.0: // %entry
190 ; CHECK-NEXT: fmsub d0, d0, d1, d2
193 %neg = fneg double %b
194 %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %neg, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
198 define double @fms64_com_strict(double %a, double %b, double %c) nounwind readnone ssp strictfp {
199 ; CHECK-LABEL: fms64_com_strict:
200 ; CHECK: // %bb.0: // %entry
201 ; CHECK-NEXT: fmsub d0, d0, d1, d2
204 %neg = fneg double %b
205 %0 = tail call double @llvm.experimental.constrained.fma.f64(double %neg, double %a, double %c, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
209 define double @fnms64_strict(double %a, double %b, double %c) nounwind readnone ssp strictfp {
210 ; CHECK-LABEL: fnms64_strict:
211 ; CHECK: // %bb.0: // %entry
212 ; CHECK-NEXT: fnmsub d0, d0, d1, d2
215 %neg = fneg double %c
216 %0 = tail call double @llvm.experimental.constrained.fma.f64(double %a, double %b, double %neg, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
220 ; This would crash while trying getNegatedExpression().
222 define float @negated_constant(float %x) {
223 ; CHECK-LABEL: negated_constant:
225 ; CHECK-NEXT: mov w8, #-1037565952 // =0xc2280000
226 ; CHECK-NEXT: fmov s1, w8
227 ; CHECK-NEXT: mov w8, #1109917696 // =0x42280000
228 ; CHECK-NEXT: fmov s2, w8
229 ; CHECK-NEXT: fmul s1, s0, s1
230 ; CHECK-NEXT: fmadd s0, s0, s2, s1
232 %m = fmul float %x, 42.0
233 %fma = call nsz float @llvm.fma.f32(float %x, float -42.0, float %m)
234 %nfma = fneg float %fma
238 attributes #0 = { strictfp }
240 declare float @llvm.fma.f32(float, float, float) nounwind readnone
241 declare double @llvm.fma.f64(double, double, double) nounwind readnone
242 declare float @llvm.experimental.constrained.fma.f32(float, float, float, metadata, metadata)
243 declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata)