blob: 2b5741a49cfc66472ce02357060228e920213698 [file] [log] [blame]
Georgios Pinitas4ee8b152021-07-16 16:16:43 +01001/*
Michael Tyler7d9a6262023-02-01 16:37:07 +00002 * Copyright (c) 2021, 2023 Arm Limited.
Georgios Pinitas4ee8b152021-07-16 16:16:43 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
Michael Tyler7d9a6262023-02-01 16:37:07 +000013 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010015 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Michael Tyler7d9a6262023-02-01 16:37:07 +000020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010023 */
24
25#pragma once
26
27#ifdef __ARM_FEATURE_SVE
28
29
30namespace {
31
32void sve_transpose_interleave_6VL_2x4(uint16_t *out, const uint16_t *in, size_t width, size_t in_stride, size_t height)
33{
34 uint16_t *pad_row = reinterpret_cast<uint16_t *>(alloca(width * sizeof(uint16_t)));
35
36 if (height % 4) {
37 memset(pad_row, 0, width * sizeof(uint16_t));
38 }
39
40 size_t out_stride = 6 * roundup<size_t>(height, 4) * get_vector_length<uint32_t>();
41
42 __asm__ __volatile__(
Michael Tylerbe13cea2023-01-17 11:04:14 +000043 "cmp %x[height], #0x8\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000044 "ptrue p2.b\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010045 "blt 6f\n"
46 "1:" // Main row loop: Head
Michael Tyler7d9a6262023-02-01 16:37:07 +000047 "mov x12, %x[in]\n"
48 "add x11, x12, %x[in_stride]\n"
49 "add x10, x11, %x[in_stride]\n"
50 "add x9, x10, %x[in_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010051 "add x28, x9, %x[in_stride]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000052 "mov x27, %x[width]\n"
53 "cnth x26, ALL, MUL #3\n"
54 "add x25, x28, %x[in_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010055 "add x24, x25, %x[in_stride]\n"
56 "add x23, x24, %x[in_stride]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000057 "cmp x27, x26\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010058 "add %x[in], x23, %x[in_stride]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000059 "mov x22, %x[out]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010060 "sub %x[height], %x[height], #0x8\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010061 "blt 3f\n"
62 "2:" // Main row loop: Unroll column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +000063 "ld1h { z18.h }, p2/Z, [x12]\n"
64 "ld1h { z13.h }, p2/Z, [x12, #1, MUL VL]\n"
65 "mov x21, x22\n"
66 "add x22, x22, %x[out_stride]\n"
67 "ld1h { z17.h }, p2/Z, [x11]\n"
68 "ld1h { z12.h }, p2/Z, [x11, #1, MUL VL]\n"
69 "mov x20, x22\n"
70 "sub x27, x27, x26\n"
71 "ld1h { z16.h }, p2/Z, [x10]\n"
72 "ld1h { z11.h }, p2/Z, [x10, #1, MUL VL]\n"
73 "zip1 z23.h, z18.h, z16.h\n"
74 "zip2 z29.h, z18.h, z16.h\n"
75 "ld1h { z16.h }, p2/Z, [x9]\n"
76 "ld1h { z10.h }, p2/Z, [x9, #1, MUL VL]\n"
77 "zip1 z22.h, z17.h, z16.h\n"
78 "zip2 z28.h, z17.h, z16.h\n"
79 "ld1h { z27.h }, p2/Z, [x28]\n"
80 "ld1h { z26.h }, p2/Z, [x25]\n"
81 "zip1 z21.h, z13.h, z11.h\n"
82 "zip1 z20.h, z12.h, z10.h\n"
83 "ld1h { z18.h }, p2/Z, [x24]\n"
84 "ld1h { z19.h }, p2/Z, [x23]\n"
85 "zip1 z17.h, z27.h, z18.h\n"
86 "zip1 z16.h, z26.h, z19.h\n"
87 "ld1h { z9.h }, p2/Z, [x12, #2, MUL VL]\n"
88 "ld1h { z8.h }, p2/Z, [x11, #2, MUL VL]\n"
89 "zip1 z25.h, z23.h, z22.h\n"
90 "zip2 z24.h, z23.h, z22.h\n"
91 "ld1h { z23.h }, p2/Z, [x10, #2, MUL VL]\n"
92 "ld1h { z7.h }, p2/Z, [x9, #2, MUL VL]\n"
93 "zip1 z22.h, z29.h, z28.h\n"
94 "zip2 z6.h, z29.h, z28.h\n"
95 "ld1h { z28.h }, p2/Z, [x28, #1, MUL VL]\n"
96 "ld1h { z5.h }, p2/Z, [x25, #1, MUL VL]\n"
97 "zip1 z4.h, z21.h, z20.h\n"
98 "zip2 z3.h, z21.h, z20.h\n"
99 "ld1h { z21.h }, p2/Z, [x24, #1, MUL VL]\n"
100 "ld1h { z20.h }, p2/Z, [x23, #1, MUL VL]\n"
101 "zip1 z2.h, z17.h, z16.h\n"
102 "zip2 z1.h, z17.h, z16.h\n"
103 "ld1h { z0.h }, p2/Z, [x28, #2, MUL VL]\n"
104 "ld1h { z31.h }, p2/Z, [x25, #2, MUL VL]\n"
105 "zip2 z18.h, z27.h, z18.h\n"
106 "zip2 z17.h, z26.h, z19.h\n"
107 "ld1h { z30.h }, p2/Z, [x24, #2, MUL VL]\n"
108 "ld1h { z29.h }, p2/Z, [x23, #2, MUL VL]\n"
109 "zip1 z19.h, z28.h, z21.h\n"
110 "zip1 z16.h, z5.h, z20.h\n"
111 "st1h { z25.h }, p2, [x21]\n"
112 "zip2 z27.h, z13.h, z11.h\n"
113 "zip2 z26.h, z12.h, z10.h\n"
114 "cmp x27, x26\n"
115 "st1h { z24.h }, p2, [x21, #1, MUL VL]\n"
116 "zip1 z25.h, z9.h, z23.h\n"
117 "zip1 z24.h, z8.h, z7.h\n"
118 "addvl x12, x12, #3\n"
119 "st1h { z22.h }, p2, [x21, #2, MUL VL]\n"
120 "zip2 z23.h, z9.h, z23.h\n"
121 "zip2 z22.h, z8.h, z7.h\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100122 "addvl x11, x11, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000123 "st1h { z6.h }, p2, [x21, #3, MUL VL]\n"
124 "zip2 z28.h, z28.h, z21.h\n"
125 "zip2 z21.h, z5.h, z20.h\n"
126 "addvl x10, x10, #3\n"
127 "st1h { z4.h }, p2, [x21, #4, MUL VL]\n"
128 "zip1 z20.h, z18.h, z17.h\n"
129 "zip2 z18.h, z18.h, z17.h\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100130 "addvl x9, x9, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000131 "st1h { z3.h }, p2, [x21, #5, MUL VL]\n"
132 "zip1 z17.h, z19.h, z16.h\n"
133 "zip2 z16.h, z19.h, z16.h\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100134 "addvl x28, x28, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000135 "st1h { z2.h }, p2, [x21, #6, MUL VL]\n"
136 "zip1 z19.h, z27.h, z26.h\n"
137 "zip2 z27.h, z27.h, z26.h\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100138 "addvl x25, x25, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000139 "st1h { z1.h }, p2, [x21, #7, MUL VL]\n"
140 "addvl x21, x21, #12\n"
141 "zip1 z26.h, z25.h, z24.h\n"
142 "zip2 z25.h, z25.h, z24.h\n"
143 "st1h { z20.h }, p2, [x21, #-4, MUL VL]\n"
144 "zip1 z24.h, z23.h, z22.h\n"
145 "zip2 z23.h, z23.h, z22.h\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100146 "addvl x24, x24, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000147 "st1h { z18.h }, p2, [x21, #-3, MUL VL]\n"
148 "zip1 z22.h, z28.h, z21.h\n"
149 "zip2 z21.h, z28.h, z21.h\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100150 "addvl x23, x23, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000151 "st1h { z17.h }, p2, [x21, #-2, MUL VL]\n"
152 "zip1 z18.h, z0.h, z30.h\n"
153 "zip1 z17.h, z31.h, z29.h\n"
154 "add x22, x22, %x[out_stride]\n"
155 "st1h { z16.h }, p2, [x21, #-1, MUL VL]\n"
156 "zip2 z20.h, z0.h, z30.h\n"
157 "zip2 z16.h, z31.h, z29.h\n"
158 "st1h { z19.h }, p2, [x20]\n"
159 "zip1 z19.h, z18.h, z17.h\n"
160 "zip2 z18.h, z18.h, z17.h\n"
161 "st1h { z27.h }, p2, [x20, #1, MUL VL]\n"
162 "zip1 z17.h, z20.h, z16.h\n"
163 "zip2 z16.h, z20.h, z16.h\n"
164 "st1h { z26.h }, p2, [x20, #2, MUL VL]\n"
165 "st1h { z25.h }, p2, [x20, #3, MUL VL]\n"
166 "st1h { z24.h }, p2, [x20, #4, MUL VL]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100167 "st1h { z23.h }, p2, [x20, #5, MUL VL]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000168 "st1h { z22.h }, p2, [x20, #6, MUL VL]\n"
169 "st1h { z21.h }, p2, [x20, #7, MUL VL]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100170 "addvl x20, x20, #12\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000171 "st1h { z19.h }, p2, [x20, #-4, MUL VL]\n"
172 "st1h { z18.h }, p2, [x20, #-3, MUL VL]\n"
173 "st1h { z17.h }, p2, [x20, #-2, MUL VL]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100174 "st1h { z16.h }, p2, [x20, #-1, MUL VL]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100175 "bge 2b\n"
176 "3:" // Main row loop: Unroll column loop skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000177 "cbz x27, 5f\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100178 "4:" // Main row loop: Column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000179 "mov x20, x27\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000180 "whilelt p1.h, XZR, x20\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000181 "ld1h { z17.h }, p1/Z, [x12]\n"
182 "ld1h { z19.h }, p1/Z, [x11]\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000183 "dech x20\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000184 "whilelt p0.h, XZR, x20\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000185 "ld1h { z22.h }, p0/Z, [x12, #1, MUL VL]\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000186 "ld1h { z21.h }, p0/Z, [x11, #1, MUL VL]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000187 "ld1h { z16.h }, p1/Z, [x10]\n"
188 "ld1h { z20.h }, p0/Z, [x10, #1, MUL VL]\n"
189 "zip1 z25.h, z17.h, z16.h\n"
190 "zip2 z24.h, z17.h, z16.h\n"
191 "ld1h { z18.h }, p1/Z, [x9]\n"
192 "ld1h { z17.h }, p0/Z, [x9, #1, MUL VL]\n"
193 "zip1 z16.h, z19.h, z18.h\n"
194 "zip2 z19.h, z19.h, z18.h\n"
195 "ld1h { z0.h }, p1/Z, [x28]\n"
196 "ld1h { z31.h }, p1/Z, [x25]\n"
197 "zip1 z23.h, z22.h, z20.h\n"
198 "zip1 z22.h, z21.h, z17.h\n"
199 "ld1h { z30.h }, p1/Z, [x24]\n"
200 "ld1h { z29.h }, p1/Z, [x23]\n"
201 "zip1 z21.h, z0.h, z30.h\n"
202 "zip1 z18.h, z31.h, z29.h\n"
203 "ld1h { z28.h }, p0/Z, [x28, #1, MUL VL]\n"
204 "ld1h { z27.h }, p0/Z, [x25, #1, MUL VL]\n"
205 "mov x20, x22\n"
206 "decd x27, ALL, MUL #6\n"
207 "ld1h { z20.h }, p0/Z, [x24, #1, MUL VL]\n"
208 "ld1h { z26.h }, p0/Z, [x23, #1, MUL VL]\n"
209 "addvl x12, x12, #1\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100210 "addvl x11, x11, #1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000211 "addvl x10, x10, #1\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000212 "addvl x9, x9, #1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000213 "zip1 z17.h, z25.h, z16.h\n"
214 "zip2 z16.h, z25.h, z16.h\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000215 "addvl x28, x28, #1\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000216 "addvl x25, x25, #1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000217 "zip1 z25.h, z24.h, z19.h\n"
218 "zip2 z19.h, z24.h, z19.h\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000219 "addvl x24, x24, #1\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000220 "addvl x23, x23, #1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000221 "zip1 z24.h, z23.h, z22.h\n"
222 "zip2 z23.h, z23.h, z22.h\n"
223 "zip1 z22.h, z21.h, z18.h\n"
224 "zip2 z21.h, z21.h, z18.h\n"
225 "st1h { z17.h }, p2, [x20]\n"
226 "cmp x27, #0x0\n"
227 "zip2 z18.h, z0.h, z30.h\n"
228 "zip2 z17.h, z31.h, z29.h\n"
229 "st1h { z16.h }, p2, [x20, #1, MUL VL]\n"
230 "incd x12, ALL, MUL #4\n"
231 "zip1 z20.h, z28.h, z20.h\n"
232 "zip1 z16.h, z27.h, z26.h\n"
233 "st1h { z25.h }, p2, [x20, #2, MUL VL]\n"
234 "incd x11, ALL, MUL #4\n"
235 "st1h { z19.h }, p2, [x20, #3, MUL VL]\n"
236 "incd x10, ALL, MUL #4\n"
237 "incd x9, ALL, MUL #4\n"
238 "zip1 z19.h, z18.h, z17.h\n"
239 "st1h { z24.h }, p2, [x20, #4, MUL VL]\n"
240 "incd x28, ALL, MUL #4\n"
241 "incd x25, ALL, MUL #4\n"
242 "zip2 z18.h, z18.h, z17.h\n"
243 "st1h { z23.h }, p2, [x20, #5, MUL VL]\n"
244 "incd x24, ALL, MUL #4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100245 "incd x23, ALL, MUL #4\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000246 "zip1 z17.h, z20.h, z16.h\n"
247 "st1h { z22.h }, p2, [x20, #6, MUL VL]\n"
248 "zip2 z16.h, z20.h, z16.h\n"
249 "add x22, x22, %x[out_stride]\n"
250 "st1h { z21.h }, p2, [x20, #7, MUL VL]\n"
251 "addvl x20, x20, #12\n"
252 "st1h { z19.h }, p2, [x20, #-4, MUL VL]\n"
253 "st1h { z18.h }, p2, [x20, #-3, MUL VL]\n"
254 "st1h { z17.h }, p2, [x20, #-2, MUL VL]\n"
255 "st1h { z16.h }, p2, [x20, #-1, MUL VL]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100256 "bgt 4b\n"
257 "5:" // Main row loop: Column loop skip
Michael Tylerbe13cea2023-01-17 11:04:14 +0000258 "cmp %x[height], #0x8\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000259 "addvl %x[out], %x[out], #12\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100260 "bge 1b\n"
261 "cbz %x[height], 12f\n"
262 "6:" // Main loop skip
263
264 "7:" // Tail row loop: Head
Michael Tyler7d9a6262023-02-01 16:37:07 +0000265 "mov x12, %x[in]\n"
266 "add x11, x12, %x[in_stride]\n"
267 "add x10, x11, %x[in_stride]\n"
268 "mov x21, %x[width]\n"
269 "cnth x20, ALL, MUL #3\n"
270 "add x9, x10, %x[in_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100271 "cmp %x[height], #0x3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000272 "add %x[in], x9, %x[in_stride]\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000273 "csel x9, x9, %x[pad_row], GT\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000274 "csel x10, x10, %x[pad_row], GE\n"
275 "cmp %x[height], #0x1\n"
276 "csel x11, x11, %x[pad_row], GT\n"
277 "cmp x21, x20\n"
278 "mov x22, %x[out]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100279 "sub %x[height], %x[height], #0x4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100280 "blt 9f\n"
281 "8:" // Tail row loop: Unroll column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000282 "ld1h { z18.h }, p2/Z, [x12]\n"
283 "ld1h { z24.h }, p2/Z, [x12, #1, MUL VL]\n"
284 "sub x21, x21, x20\n"
285 "cmp x21, x20\n"
286 "ld1h { z17.h }, p2/Z, [x11]\n"
287 "ld1h { z23.h }, p2/Z, [x11, #1, MUL VL]\n"
288 "ld1h { z16.h }, p2/Z, [x10]\n"
289 "ld1h { z22.h }, p2/Z, [x10, #1, MUL VL]\n"
290 "zip1 z31.h, z18.h, z16.h\n"
291 "zip2 z30.h, z18.h, z16.h\n"
292 "ld1h { z16.h }, p2/Z, [x9]\n"
293 "ld1h { z20.h }, p2/Z, [x9, #1, MUL VL]\n"
294 "zip1 z29.h, z17.h, z16.h\n"
295 "zip2 z28.h, z17.h, z16.h\n"
296 "ld1h { z19.h }, p2/Z, [x12, #2, MUL VL]\n"
297 "ld1h { z18.h }, p2/Z, [x11, #2, MUL VL]\n"
298 "zip1 z27.h, z24.h, z22.h\n"
299 "zip1 z21.h, z23.h, z20.h\n"
300 "ld1h { z17.h }, p2/Z, [x10, #2, MUL VL]\n"
301 "ld1h { z16.h }, p2/Z, [x9, #2, MUL VL]\n"
302 "zip2 z26.h, z24.h, z22.h\n"
303 "zip2 z20.h, z23.h, z20.h\n"
304 "zip1 z25.h, z19.h, z17.h\n"
305 "zip1 z24.h, z18.h, z16.h\n"
306 "addvl x12, x12, #3\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100307 "addvl x11, x11, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000308 "zip2 z23.h, z19.h, z17.h\n"
309 "zip2 z22.h, z18.h, z16.h\n"
310 "addvl x10, x10, #3\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100311 "addvl x9, x9, #3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000312 "zip1 z17.h, z31.h, z29.h\n"
313 "zip2 z16.h, z31.h, z29.h\n"
314 "st1h { z17.h }, p2, [x22]\n"
315 "zip1 z19.h, z30.h, z28.h\n"
316 "zip2 z18.h, z30.h, z28.h\n"
317 "st1h { z16.h }, p2, [x22, #1, MUL VL]\n"
318 "zip1 z17.h, z27.h, z21.h\n"
319 "zip2 z16.h, z27.h, z21.h\n"
320 "st1h { z19.h }, p2, [x22, #2, MUL VL]\n"
321 "st1h { z18.h }, p2, [x22, #3, MUL VL]\n"
322 "zip1 z21.h, z26.h, z20.h\n"
323 "zip2 z20.h, z26.h, z20.h\n"
324 "st1h { z17.h }, p2, [x22, #4, MUL VL]\n"
325 "zip1 z19.h, z25.h, z24.h\n"
326 "zip2 z18.h, z25.h, z24.h\n"
327 "st1h { z16.h }, p2, [x22, #5, MUL VL]\n"
328 "add x22, x22, %x[out_stride]\n"
329 "zip1 z17.h, z23.h, z22.h\n"
330 "zip2 z16.h, z23.h, z22.h\n"
331 "st1h { z21.h }, p2, [x22]\n"
332 "st1h { z20.h }, p2, [x22, #1, MUL VL]\n"
333 "st1h { z19.h }, p2, [x22, #2, MUL VL]\n"
334 "st1h { z18.h }, p2, [x22, #3, MUL VL]\n"
335 "st1h { z17.h }, p2, [x22, #4, MUL VL]\n"
336 "st1h { z16.h }, p2, [x22, #5, MUL VL]\n"
337 "add x22, x22, %x[out_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100338 "bge 8b\n"
339 "9:" // Tail row loop: Unroll column loop skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000340 "cbz x21, 11f\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100341 "10:" // Tail row loop: Column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000342 "mov x20, x21\n"
343 "whilelt p1.h, XZR, x20\n"
344 "ld1h { z22.h }, p1/Z, [x12]\n"
345 "ld1h { z25.h }, p1/Z, [x11]\n"
346 "dech x20\n"
347 "whilelt p0.h, XZR, x20\n"
348 "ld1h { z24.h }, p0/Z, [x12, #1, MUL VL]\n"
349 "ld1h { z23.h }, p0/Z, [x11, #1, MUL VL]\n"
350 "ld1h { z21.h }, p1/Z, [x10]\n"
351 "ld1h { z20.h }, p0/Z, [x10, #1, MUL VL]\n"
352 "decd x21, ALL, MUL #6\n"
353 "addvl x12, x12, #1\n"
354 "ld1h { z18.h }, p1/Z, [x9]\n"
355 "ld1h { z17.h }, p0/Z, [x9, #1, MUL VL]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100356 "addvl x11, x11, #1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000357 "addvl x10, x10, #1\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000358 "addvl x9, x9, #1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000359 "zip1 z19.h, z22.h, z21.h\n"
360 "zip1 z16.h, z25.h, z18.h\n"
361 "cmp x21, #0x0\n"
362 "zip2 z22.h, z22.h, z21.h\n"
363 "zip2 z18.h, z25.h, z18.h\n"
364 "incd x12, ALL, MUL #4\n"
365 "incd x11, ALL, MUL #4\n"
366 "zip1 z21.h, z24.h, z20.h\n"
367 "zip1 z20.h, z23.h, z17.h\n"
368 "incd x10, ALL, MUL #4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100369 "incd x9, ALL, MUL #4\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000370 "zip1 z17.h, z19.h, z16.h\n"
371 "zip2 z16.h, z19.h, z16.h\n"
372 "st1h { z17.h }, p2, [x22]\n"
373 "zip1 z19.h, z22.h, z18.h\n"
374 "zip2 z18.h, z22.h, z18.h\n"
375 "st1h { z16.h }, p2, [x22, #1, MUL VL]\n"
376 "zip1 z17.h, z21.h, z20.h\n"
377 "zip2 z16.h, z21.h, z20.h\n"
378 "st1h { z19.h }, p2, [x22, #2, MUL VL]\n"
379 "st1h { z18.h }, p2, [x22, #3, MUL VL]\n"
380 "st1h { z17.h }, p2, [x22, #4, MUL VL]\n"
381 "st1h { z16.h }, p2, [x22, #5, MUL VL]\n"
382 "add x22, x22, %x[out_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100383 "bgt 10b\n"
384 "11:" // Tail row loop: Column loop skip
Michael Tylerbe13cea2023-01-17 11:04:14 +0000385 "cmp %x[height], #0x1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000386 "addvl %x[out], %x[out], #6\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100387 "bge 7b\n"
388 "12:" // Done
389
390 : [height] "+&r" (height), [in] "+&r" (in), [out] "+&r" (out)
391 : [in_stride] "r" (in_stride), [out_stride] "r" (out_stride), [pad_row] "r" (pad_row), [width] "r" (width)
Michael Tyler7d9a6262023-02-01 16:37:07 +0000392 : "cc", "memory", "p0", "p1", "p2", "x9", "x10", "x11", "x12", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8", "z9", "z10", "z11", "z12", "z13", "z16", "z17", "z18", "z19", "z20", "z21", "z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100393 );
394}
395
396} // anonymous namespace
397
398template<>
399void Transform<6, 4, true, VLType::SVE>(
400 bfloat16 *out, const bfloat16 *in, int stride, int x0, int xmax, int k0, int kmax)
401{
402 sve_transpose_interleave_6VL_2x4(
403 reinterpret_cast<uint16_t *>(out),
404 reinterpret_cast<const uint16_t *>(in + k0 * stride + x0),
405 (xmax-x0) * sizeof(bfloat16) / 2,
406 stride * sizeof(bfloat16),
407 (kmax-k0)
408 );
409}
410
411#endif