1 ; RUN: llc < %s -O=3 -mtriple=arm64-apple-ios -mcpu=cyclone -mattr=+fullfp16 -enable-unsafe-fp-math -verify-machineinstrs | FileCheck %s
3 define void @foo_2d(ptr %src) {
5 ; CHECK: fmul {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
6 ; CHECK: fmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
8 %arrayidx1 = getelementptr inbounds double, ptr %src, i64 5
9 %arrayidx2 = getelementptr inbounds double, ptr %src, i64 11
10 %tmp1 = load double, ptr %arrayidx2, align 8
11 %tmp2 = load double, ptr %arrayidx1, align 8
12 %fmul = fmul fast double %tmp1, %tmp1
13 %fmul2 = fmul fast double %tmp2, 0x3F94AFD6A052BF5B
14 %fadd = fadd fast double %fmul, %fmul2
17 ; CHECK-LABEL: %for.body
18 ; CHECK: fmla.2d {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}
19 ; CHECK: fmla.2d {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
20 ; CHECK: fmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
21 for.body: ; preds = %for.body, %entry
22 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
23 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
24 %arrayidx3 = getelementptr inbounds double, ptr %src, i64 %indvars.iv.next
25 %tmp3 = load double, ptr %arrayidx3, align 8
26 %add = fadd fast double %tmp3, %tmp3
27 %mul = fmul fast double %add, %fadd
28 %e1 = insertelement <2 x double> undef, double %add, i32 0
29 %e2 = insertelement <2 x double> %e1, double %add, i32 1
30 %add2 = fadd fast <2 x double> %e2, <double 3.000000e+00, double -3.000000e+00>
31 %e3 = insertelement <2 x double> undef, double %mul, i32 0
32 %e4 = insertelement <2 x double> %e3, double %mul, i32 1
33 %mul2 = fmul fast <2 x double> %add2,<double 3.000000e+00, double -3.000000e+00>
34 %e5 = insertelement <2 x double> undef, double %add, i32 0
35 %e6 = insertelement <2 x double> %e5, double %add, i32 1
36 %add3 = fadd fast <2 x double> %mul2, <double 3.000000e+00, double -3.000000e+00>
37 %mulx = fmul fast <2 x double> %add2, %e2
38 %addx = fadd fast <2 x double> %mulx, %e4
39 %e7 = insertelement <2 x double> undef, double %mul, i32 0
40 %e8 = insertelement <2 x double> %e7, double %mul, i32 1
41 %e9 = fmul fast <2 x double> %addx, %add3
42 store <2 x double> %e9, ptr %arrayidx1, align 8
43 %e10 = extractelement <2 x double> %add3, i32 0
44 %mul3 = fmul fast double %mul, %e10
45 %add4 = fadd fast double %mul3, %mul
46 store double %add4, ptr %arrayidx2, align 8
47 %exitcond = icmp eq i64 %indvars.iv.next, 25
48 br i1 %exitcond, label %for.end, label %for.body
50 for.end: ; preds = %for.body
53 define void @foo_2s(ptr %src) {
55 %arrayidx1 = getelementptr inbounds float, ptr %src, i64 5
56 %arrayidx2 = getelementptr inbounds float, ptr %src, i64 11
59 ; CHECK-LABEL: %for.body
60 ; CHECK: fmla.2s {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}
61 ; CHECK: fmla.2s {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
62 ; CHECK: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
63 for.body: ; preds = %for.body, %entry
64 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
65 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
66 %arrayidx3 = getelementptr inbounds float, ptr %src, i64 %indvars.iv.next
67 %tmp1 = load float, ptr %arrayidx3, align 8
68 %add = fadd fast float %tmp1, %tmp1
69 %mul = fmul fast float %add, %add
70 %e1 = insertelement <2 x float> undef, float %add, i32 0
71 %e2 = insertelement <2 x float> %e1, float %add, i32 1
72 %add2 = fadd fast <2 x float> %e2, <float 3.000000e+00, float -3.000000e+00>
73 %e3 = insertelement <2 x float> undef, float %mul, i32 0
74 %e4 = insertelement <2 x float> %e3, float %mul, i32 1
75 %mul2 = fmul fast <2 x float> %add2,<float 3.000000e+00, float -3.000000e+00>
76 %e5 = insertelement <2 x float> undef, float %add, i32 0
77 %e6 = insertelement <2 x float> %e5, float %add, i32 1
78 %add3 = fadd fast <2 x float> %mul2, <float 3.000000e+00, float -3.000000e+00>
79 %mulx = fmul fast <2 x float> %add2, %e2
80 %addx = fadd fast <2 x float> %mulx, %e4
81 %e7 = insertelement <2 x float> undef, float %mul, i32 0
82 %e8 = insertelement <2 x float> %e7, float %mul, i32 1
83 %e9 = fmul fast <2 x float> %addx, %add3
84 store <2 x float> %e9, ptr %arrayidx1, align 8
85 %e10 = extractelement <2 x float> %add3, i32 0
86 %mul3 = fmul fast float %mul, %e10
87 %add4 = fadd fast float %mul3, %mul
88 store float %add4, ptr %arrayidx2, align 8
89 %exitcond = icmp eq i64 %indvars.iv.next, 25
90 br i1 %exitcond, label %for.end, label %for.body
92 for.end: ; preds = %for.body
95 define void @foo_4s(ptr %src) {
97 %arrayidx1 = getelementptr inbounds float, ptr %src, i64 5
98 %arrayidx2 = getelementptr inbounds float, ptr %src, i64 11
101 ; CHECK-LABEL: %for.body
102 ; CHECK: fmla.4s {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}
103 ; CHECK: fmla.4s {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
104 for.body: ; preds = %for.body, %entry
105 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
106 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
107 %arrayidx3 = getelementptr inbounds float, ptr %src, i64 %indvars.iv.next
108 %tmp1 = load float, ptr %arrayidx3, align 8
109 %add = fadd fast float %tmp1, %tmp1
110 %mul = fmul fast float %add, %add
111 %e1 = insertelement <4 x float> undef, float %add, i32 0
112 %e2 = insertelement <4 x float> %e1, float %add, i32 1
113 %add2 = fadd fast <4 x float> %e2, <float 3.000000e+00, float -3.000000e+00, float 5.000000e+00, float 7.000000e+00>
114 %e3 = insertelement <4 x float> undef, float %mul, i32 0
115 %e4 = insertelement <4 x float> %e3, float %mul, i32 1
116 %mul2 = fmul fast <4 x float> %add2,<float 3.000000e+00, float -3.000000e+00, float 5.000000e+00, float 7.000000e+00>
117 %e5 = insertelement <4 x float> undef, float %add, i32 0
118 %e6 = insertelement <4 x float> %e5, float %add, i32 1
119 %add3 = fadd fast <4 x float> %mul2, <float 3.000000e+00, float -3.000000e+00, float 5.000000e+00, float 7.000000e+00>
120 %mulx = fmul fast <4 x float> %add2, %e2
121 %addx = fadd fast <4 x float> %mulx, %e4
122 %e7 = insertelement <4 x float> undef, float %mul, i32 0
123 %e8 = insertelement <4 x float> %e7, float %mul, i32 1
124 %e9 = fmul fast <4 x float> %addx, %add3
125 store <4 x float> %e9, ptr %arrayidx1, align 8
126 %e10 = extractelement <4 x float> %add3, i32 0
127 %mul3 = fmul fast float %mul, %e10
128 store float %mul3, ptr %arrayidx2, align 8
129 %exitcond = icmp eq i64 %indvars.iv.next, 25
130 br i1 %exitcond, label %for.end, label %for.body
132 for.end: ; preds = %for.body
136 define void @indexed_2s(<2 x float> %shuf, <2 x float> %add,
137 ptr %pmul, ptr %pret) {
138 ; CHECK-LABEL: %entry
140 ; CHECK: fmla.2s {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
143 %shuffle = shufflevector <2 x float> %shuf, <2 x float> undef, <2 x i32> zeroinitializer
147 %i = phi i64 [ 0, %entry ], [ %inext, %for.body ]
148 %pmul_i = getelementptr inbounds <2 x float>, ptr %pmul, i64 %i
149 %pret_i = getelementptr inbounds <2 x float>, ptr %pret, i64 %i
151 %mul_i = load <2 x float>, ptr %pmul_i
153 %mul = fmul fast <2 x float> %mul_i, %shuffle
154 %muladd = fadd fast <2 x float> %mul, %add
156 store <2 x float> %muladd, ptr %pret_i, align 16
157 %inext = add i64 %i, 1
161 define void @indexed_2d(<2 x double> %shuf, <2 x double> %add,
162 ptr %pmul, ptr %pret) {
163 ; CHECK-LABEL: %entry
165 ; CHECK: fmla.2d {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
168 %shuffle = shufflevector <2 x double> %shuf, <2 x double> undef, <2 x i32> zeroinitializer
172 %i = phi i64 [ 0, %entry ], [ %inext, %for.body ]
173 %pmul_i = getelementptr inbounds <2 x double>, ptr %pmul, i64 %i
174 %pret_i = getelementptr inbounds <2 x double>, ptr %pret, i64 %i
176 %mul_i = load <2 x double>, ptr %pmul_i
178 %mul = fmul fast <2 x double> %mul_i, %shuffle
179 %muladd = fadd fast <2 x double> %mul, %add
181 store <2 x double> %muladd, ptr %pret_i, align 16
182 %inext = add i64 %i, 1
186 define void @indexed_4s(<4 x float> %shuf, <4 x float> %add,
187 ptr %pmul, ptr %pret) {
188 ; CHECK-LABEL: %entry
190 ; CHECK: fmla.4s {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
193 %shuffle = shufflevector <4 x float> %shuf, <4 x float> undef, <4 x i32> zeroinitializer
197 %i = phi i64 [ 0, %entry ], [ %inext, %for.body ]
198 %pmul_i = getelementptr inbounds <4 x float>, ptr %pmul, i64 %i
199 %pret_i = getelementptr inbounds <4 x float>, ptr %pret, i64 %i
201 %mul_i = load <4 x float>, ptr %pmul_i
203 %mul = fmul fast <4 x float> %mul_i, %shuffle
204 %muladd = fadd fast <4 x float> %mul, %add
206 store <4 x float> %muladd, ptr %pret_i, align 16
207 %inext = add i64 %i, 1
211 define void @indexed_4h(<4 x half> %shuf, <4 x half> %add,
212 ptr %pmul, ptr %pret) {
213 ; CHECK-LABEL: %entry
215 ; CHECK: fmla.4h {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
218 %shuffle = shufflevector <4 x half> %shuf, <4 x half> undef, <4 x i32> zeroinitializer
222 %i = phi i64 [ 0, %entry ], [ %inext, %for.body ]
223 %pmul_i = getelementptr inbounds <4 x half>, ptr %pmul, i64 %i
224 %pret_i = getelementptr inbounds <4 x half>, ptr %pret, i64 %i
226 %mul_i = load <4 x half>, ptr %pmul_i
228 %mul = fmul fast <4 x half> %mul_i, %shuffle
229 %muladd = fadd fast <4 x half> %mul, %add
231 store <4 x half> %muladd, ptr %pret_i, align 16
232 %inext = add i64 %i, 1
236 define void @indexed_8h(<8 x half> %shuf, <8 x half> %add,
237 ptr %pmul, ptr %pret) {
238 ; CHECK-LABEL: %entry
240 ; CHECK: fmla.8h {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}[0]
243 %shuffle = shufflevector <8 x half> %shuf, <8 x half> undef, <8 x i32> zeroinitializer
247 %i = phi i64 [ 0, %entry ], [ %inext, %for.body ]
248 %pmul_i = getelementptr inbounds <8 x half>, ptr %pmul, i64 %i
249 %pret_i = getelementptr inbounds <8 x half>, ptr %pret, i64 %i
251 %mul_i = load <8 x half>, ptr %pmul_i
253 %mul = fmul fast <8 x half> %mul_i, %shuffle
254 %muladd = fadd fast <8 x half> %mul, %add
256 store <8 x half> %muladd, ptr %pret_i, align 16
257 %inext = add i64 %i, 1