| 1 |
/* |
| 2 |
dct36_avx: AVX optimized dct36 for x86-64 |
| 3 |
|
| 4 |
copyright 1995-2026 by the mpg123 project - free software under the terms of the LGPL 2.1 |
| 5 |
see COPYING and AUTHORS files in distribution or http://mpg123.org |
| 6 |
initially written by Taihei Monma |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "x86_64_defs.h" |
| 10 |
#include "mangle.h" |
| 11 |
|
| 12 |
#ifdef IS_MSABI |
| 13 |
#define in %rcx |
| 14 |
#define out1 %rdx |
| 15 |
#define out2 %r8 |
| 16 |
#define w %r9 |
| 17 |
#define ts %r10 |
| 18 |
#define COS9_ %rax |
| 19 |
#define tfcos36_ %r11 |
| 20 |
#else |
| 21 |
#define in %rdi |
| 22 |
#define out1 %rsi |
| 23 |
#define out2 %rdx |
| 24 |
#define w %rcx |
| 25 |
#define ts %r8 |
| 26 |
#define COS9_ %rax |
| 27 |
#define tfcos36_ %r9 |
| 28 |
#endif |
| 29 |
|
| 30 |
/* |
| 31 |
void dct36_avx(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf); |
| 32 |
*/ |
| 33 |
|
| 34 |
RODATA |
| 35 |
ALIGN16 |
| 36 |
dct36_avx_COS9: |
| 37 |
.long 0x3f5db3d7 |
| 38 |
.long 0x3f5db3d7 |
| 39 |
.long 0x3f000000 |
| 40 |
.long 0x3f000000 |
| 41 |
.long 0x3f7c1c5c |
| 42 |
.long 0x3f7c1c5c |
| 43 |
.long 0x3f708fb2 |
| 44 |
.long 0x3f708fb2 |
| 45 |
.long 0x3f248dbb |
| 46 |
.long 0x3f248dbb |
| 47 |
.long 0x3e31d0d4 |
| 48 |
.long 0x3e31d0d4 |
| 49 |
.long 0x3eaf1d44 |
| 50 |
.long 0x3eaf1d44 |
| 51 |
.long 0x3f441b7d |
| 52 |
.long 0x3f441b7d |
| 53 |
ALIGN16 |
| 54 |
dct36_avx_tfcos36: |
| 55 |
.long 0x3f007d2b |
| 56 |
.long 0x3f0483ee |
| 57 |
.long 0x3f0d3b7d |
| 58 |
.long 0x3f1c4257 |
| 59 |
.long 0x40b79454 |
| 60 |
.long 0x3ff746ea |
| 61 |
.long 0x3f976fd9 |
| 62 |
.long 0x3f5f2944 |
| 63 |
.long 0x3f3504f3 |
| 64 |
ALIGN16 |
| 65 |
dct36_avx_sign: |
| 66 |
.long 0x80000000,0x80000000,0x80000000,0x80000000 |
| 67 |
.text |
| 68 |
ALIGN16 |
| 69 |
.globl ASM_NAME(INT123_dct36_avx) |
| 70 |
ASM_NAME(INT123_dct36_avx): |
| 71 |
#ifdef IS_MSABI |
| 72 |
push %rbp |
| 73 |
mov %rsp, %rbp |
| 74 |
sub $160, %rsp |
| 75 |
movaps %xmm6, (%rsp) |
| 76 |
movaps %xmm7, 16(%rsp) |
| 77 |
movaps %xmm8, 32(%rsp) |
| 78 |
movaps %xmm9, 48(%rsp) |
| 79 |
movaps %xmm10, 64(%rsp) |
| 80 |
movaps %xmm11, 80(%rsp) |
| 81 |
movaps %xmm12, 96(%rsp) |
| 82 |
movaps %xmm13, 112(%rsp) |
| 83 |
movaps %xmm14, 128(%rsp) |
| 84 |
movaps %xmm15, 144(%rsp) |
| 85 |
movq 48(%rbp), ts |
| 86 |
#endif |
| 87 |
lea dct36_avx_COS9(%rip), COS9_ |
| 88 |
lea dct36_avx_tfcos36(%rip), tfcos36_ |
| 89 |
|
| 90 |
xorps %xmm4, %xmm4 |
| 91 |
movups (in), %xmm0 |
| 92 |
movups 16(in), %xmm1 |
| 93 |
movups 32(in), %xmm2 |
| 94 |
movups 48(in), %xmm3 |
| 95 |
movlps 64(in), %xmm4 |
| 96 |
vshufps $0x93, %xmm0, %xmm0, %xmm5 |
| 97 |
vshufps $0x93, %xmm1, %xmm1, %xmm6 |
| 98 |
vshufps $0x93, %xmm2, %xmm2, %xmm7 |
| 99 |
vshufps $0x93, %xmm3, %xmm3, %xmm8 |
| 100 |
vshufps $0xe1, %xmm4, %xmm4, %xmm9 |
| 101 |
movss %xmm8, %xmm9 #[fg--] |
| 102 |
addps %xmm9, %xmm4 #[gh--] |
| 103 |
movss %xmm7, %xmm8 |
| 104 |
addps %xmm8, %xmm3 #[cdef] |
| 105 |
movss %xmm6, %xmm7 |
| 106 |
addps %xmm7, %xmm2 #[89ab] |
| 107 |
movss %xmm5, %xmm6 |
| 108 |
addps %xmm6, %xmm1 #[4567] |
| 109 |
xorps %xmm6, %xmm6 |
| 110 |
movss %xmm6, %xmm5 |
| 111 |
addps %xmm5, %xmm0 #[0123] |
| 112 |
|
| 113 |
vblendps $0x5, %xmm6, %xmm3, %xmm7 |
| 114 |
vshufps $0x4e, %xmm4, %xmm3, %xmm4 |
| 115 |
addps %xmm7, %xmm4 |
| 116 |
vblendps $0x5, %xmm6, %xmm2, %xmm7 |
| 117 |
vshufps $0x4e, %xmm3, %xmm2, %xmm3 |
| 118 |
addps %xmm7, %xmm3 |
| 119 |
vblendps $0x5, %xmm6, %xmm1, %xmm7 |
| 120 |
vshufps $0x4e, %xmm2, %xmm1, %xmm2 |
| 121 |
addps %xmm7, %xmm2 |
| 122 |
vblendps $0x5, %xmm6, %xmm0, %xmm7 |
| 123 |
vshufps $0x4e, %xmm1, %xmm0, %xmm1 |
| 124 |
addps %xmm7, %xmm1 |
| 125 |
vmovlhps %xmm0, %xmm6, %xmm0 |
| 126 |
|
| 127 |
/* |
| 128 |
xmm0 in[-,-,0,1] |
| 129 |
xmm1 in[2,3,4,5] |
| 130 |
xmm2 in[6,7,8,9] |
| 131 |
xmm3 in[10,11,12,13] |
| 132 |
xmm4 in[14,15,16,17] |
| 133 |
*/ |
| 134 |
|
| 135 |
vblendps $0xc, %xmm3, %xmm2, %xmm5 |
| 136 |
blendps $0xc, %xmm4, %xmm3 |
| 137 |
blendps $0xc, %xmm2, %xmm4 |
| 138 |
movaps %xmm5, %xmm2 |
| 139 |
|
| 140 |
/* |
| 141 |
xmm2 in[6,7,12,13] |
| 142 |
xmm3 in[10,11,16,17] |
| 143 |
xmm4 in[14,15,8,9] |
| 144 |
*/ |
| 145 |
|
| 146 |
movaps (COS9_), %xmm15 |
| 147 |
movaps 16(COS9_), %xmm6 |
| 148 |
movaps 32(COS9_), %xmm7 |
| 149 |
movaps 48(COS9_), %xmm8 |
| 150 |
vmulps %xmm2, %xmm15, %xmm5 |
| 151 |
addps %xmm0, %xmm5 |
| 152 |
|
| 153 |
/* |
| 154 |
xmm5 [ta33,tb33,ta66,tb66] |
| 155 |
xmm6 COS9_[1,1,2,2] |
| 156 |
xmm7 COS9_[5,5,8,8] |
| 157 |
xmm8 COS9_[7,7,4,4] |
| 158 |
xmm15 COS9_[3,3,6,6] |
| 159 |
*/ |
| 160 |
|
| 161 |
vmulps %xmm1, %xmm6, %xmm9 |
| 162 |
vmulps %xmm3, %xmm7, %xmm12 |
| 163 |
vmulps %xmm4, %xmm8, %xmm13 |
| 164 |
addps %xmm5, %xmm9 |
| 165 |
addps %xmm13, %xmm12 |
| 166 |
addps %xmm9, %xmm12 |
| 167 |
|
| 168 |
vsubps %xmm3, %xmm1, %xmm13 |
| 169 |
vshufps $0xe0, %xmm2, %xmm0, %xmm14 |
| 170 |
vsubps %xmm14, %xmm0, %xmm14 |
| 171 |
subps %xmm4, %xmm13 |
| 172 |
mulps %xmm15, %xmm13 |
| 173 |
addps %xmm14, %xmm13 |
| 174 |
|
| 175 |
vmulps %xmm1, %xmm7, %xmm9 |
| 176 |
vmulps %xmm3, %xmm8, %xmm15 |
| 177 |
vmulps %xmm4, %xmm6, %xmm14 |
| 178 |
subps %xmm5, %xmm9 |
| 179 |
subps %xmm15, %xmm14 |
| 180 |
addps %xmm9, %xmm14 |
| 181 |
|
| 182 |
mulps %xmm1, %xmm8 |
| 183 |
mulps %xmm3, %xmm6 |
| 184 |
mulps %xmm4, %xmm7 |
| 185 |
subps %xmm5, %xmm8 |
| 186 |
subps %xmm7, %xmm6 |
| 187 |
vaddps %xmm6, %xmm8, %xmm15 |
| 188 |
|
| 189 |
movss 32(tfcos36_), %xmm5 |
| 190 |
subps %xmm1, %xmm0 |
| 191 |
subps %xmm2, %xmm4 |
| 192 |
addps %xmm3, %xmm0 |
| 193 |
addps %xmm4, %xmm0 |
| 194 |
shufps $0xaf, %xmm0, %xmm0 |
| 195 |
vmulss %xmm5, %xmm0, %xmm11 |
| 196 |
|
| 197 |
/* |
| 198 |
xmm12 [1a-0,1b-0, 2a-0, 2b-0] |
| 199 |
xmm13 [1a-1,1b-1, 2a-1, 2b-1] |
| 200 |
xmm14 [1a-2,1b-2,-2a-2,-2b-2] |
| 201 |
xmm15 [1a-3,1b-3,-2a-3,-2b-3] |
| 202 |
*/ |
| 203 |
vunpckhps %xmm13, %xmm12, %xmm5 |
| 204 |
vunpcklps %xmm13, %xmm12, %xmm12 |
| 205 |
vunpckhps %xmm15, %xmm14, %xmm6 |
| 206 |
vunpcklps %xmm15, %xmm14, %xmm14 |
| 207 |
xorps dct36_avx_sign(%rip), %xmm6 |
| 208 |
|
| 209 |
/* |
| 210 |
xmm12 [1a-0,1a-1,1b-0,1b-1] |
| 211 |
xmm5 [2a-0,2a-1,2b-0,2b-1] |
| 212 |
xmm14 [1a-2,1a-3,1b-2,1b-3] |
| 213 |
xmm6 [2a-2,2a-3,2b-2,2b-3] |
| 214 |
*/ |
| 215 |
|
| 216 |
vmovlhps %xmm14, %xmm12, %xmm0 |
| 217 |
movhlps %xmm12, %xmm14 |
| 218 |
vmovlhps %xmm6, %xmm5, %xmm1 |
| 219 |
vmovhlps %xmm5, %xmm6, %xmm15 |
| 220 |
|
| 221 |
/* |
| 222 |
xmm0 tmp1a |
| 223 |
xmm1 tmp2a |
| 224 |
xmm14 tmp1b |
| 225 |
xmm15 tmp2b |
| 226 |
*/ |
| 227 |
|
| 228 |
movaps (tfcos36_), %xmm6 |
| 229 |
movaps 16(tfcos36_), %xmm7 |
| 230 |
vsubps %xmm14, %xmm15, %xmm10 |
| 231 |
addps %xmm14, %xmm15 |
| 232 |
vsubps %xmm0, %xmm1, %xmm14 |
| 233 |
addps %xmm1, %xmm0 |
| 234 |
vmulps %xmm6, %xmm15, %xmm1 |
| 235 |
mulps %xmm10, %xmm7 |
| 236 |
|
| 237 |
/* |
| 238 |
%xmm0 tmp[0,1,2,3] |
| 239 |
%xmm1 tmp[17,16,15,14] |
| 240 |
%xmm14 tmp[8,7,6,5] |
| 241 |
%xmm7 tmp[9,10,11,12] |
| 242 |
%xmm11 tmp[13,-,4,-] |
| 243 |
*/ |
| 244 |
|
| 245 |
movups 108(w), %xmm2 |
| 246 |
movups 92(w), %xmm3 |
| 247 |
shufps $0x1b, %xmm3, %xmm3 |
| 248 |
movups 36(w), %xmm4 |
| 249 |
movups 20(w), %xmm5 |
| 250 |
shufps $0x1b, %xmm5, %xmm5 |
| 251 |
vsubps %xmm1, %xmm0, %xmm6 |
| 252 |
addps %xmm1, %xmm0 |
| 253 |
mulps %xmm0, %xmm2 |
| 254 |
mulps %xmm3, %xmm0 |
| 255 |
mulps %xmm6, %xmm4 |
| 256 |
mulps %xmm5, %xmm6 |
| 257 |
movups 36(out1), %xmm1 |
| 258 |
movups 20(out1), %xmm3 |
| 259 |
shufps $0x1b, %xmm6, %xmm6 |
| 260 |
addps %xmm4, %xmm1 |
| 261 |
addps %xmm6, %xmm3 |
| 262 |
shufps $0x1b, %xmm0, %xmm0 |
| 263 |
movups %xmm2, 36(out2) |
| 264 |
movups %xmm0, 20(out2) |
| 265 |
movss %xmm1, 32*36(ts) |
| 266 |
movss %xmm3, 32*20(ts) |
| 267 |
movhlps %xmm1, %xmm2 |
| 268 |
movhlps %xmm3, %xmm4 |
| 269 |
movss %xmm2, 32*44(ts) |
| 270 |
movss %xmm4, 32*28(ts) |
| 271 |
shufps $0xb1, %xmm1, %xmm1 |
| 272 |
shufps $0xb1, %xmm3, %xmm3 |
| 273 |
movss %xmm1, 32*40(ts) |
| 274 |
movss %xmm3, 32*24(ts) |
| 275 |
movhlps %xmm1, %xmm2 |
| 276 |
movhlps %xmm3, %xmm4 |
| 277 |
movss %xmm2, 32*48(ts) |
| 278 |
movss %xmm4, 32*32(ts) |
| 279 |
|
| 280 |
movhlps %xmm11, %xmm0 |
| 281 |
movss 124(w), %xmm2 |
| 282 |
movss 88(w), %xmm3 |
| 283 |
movss 52(w), %xmm4 |
| 284 |
movss 16(w), %xmm5 |
| 285 |
movss %xmm0, %xmm6 |
| 286 |
addss %xmm11, %xmm0 |
| 287 |
subss %xmm11, %xmm6 |
| 288 |
mulss %xmm0, %xmm2 |
| 289 |
mulss %xmm3, %xmm0 |
| 290 |
mulss %xmm6, %xmm4 |
| 291 |
mulss %xmm5, %xmm6 |
| 292 |
addss 52(out1), %xmm4 |
| 293 |
addss 16(out1), %xmm6 |
| 294 |
movss %xmm2, 52(out2) |
| 295 |
movss %xmm0, 16(out2) |
| 296 |
movss %xmm4, 32*52(ts) |
| 297 |
movss %xmm6, 32*16(ts) |
| 298 |
|
| 299 |
movaps %xmm14, %xmm0 |
| 300 |
movaps %xmm7, %xmm1 |
| 301 |
MOVUAPS 128(w), %xmm2 |
| 302 |
movups 72(w), %xmm3 |
| 303 |
shufps $0x1b, %xmm2, %xmm2 |
| 304 |
movlps 56(w), %xmm4 |
| 305 |
movhps 64(w), %xmm4 |
| 306 |
MOVUAPS (w), %xmm5 |
| 307 |
shufps $0x1b, %xmm4, %xmm4 |
| 308 |
vsubps %xmm1, %xmm0, %xmm6 |
| 309 |
addps %xmm1, %xmm0 |
| 310 |
mulps %xmm0, %xmm2 |
| 311 |
mulps %xmm3, %xmm0 |
| 312 |
mulps %xmm6, %xmm4 |
| 313 |
mulps %xmm5, %xmm6 |
| 314 |
movlps 56(out1), %xmm1 |
| 315 |
movhps 64(out1), %xmm1 |
| 316 |
movups (out1), %xmm3 |
| 317 |
shufps $0x1b, %xmm4, %xmm4 |
| 318 |
addps %xmm6, %xmm3 |
| 319 |
addps %xmm4, %xmm1 |
| 320 |
shufps $0x1b, %xmm2, %xmm2 |
| 321 |
movups %xmm0, (out2) |
| 322 |
movlps %xmm2, 56(out2) |
| 323 |
movhps %xmm2, 64(out2) |
| 324 |
movss %xmm1, 32*56(ts) |
| 325 |
movss %xmm3, (ts) |
| 326 |
movhlps %xmm1, %xmm2 |
| 327 |
movhlps %xmm3, %xmm4 |
| 328 |
movss %xmm2, 32*64(ts) |
| 329 |
movss %xmm4, 32*8(ts) |
| 330 |
shufps $0xb1, %xmm1, %xmm1 |
| 331 |
shufps $0xb1, %xmm3, %xmm3 |
| 332 |
movss %xmm1, 32*60(ts) |
| 333 |
movss %xmm3, 32*4(ts) |
| 334 |
movhlps %xmm1, %xmm2 |
| 335 |
movhlps %xmm3, %xmm4 |
| 336 |
movss %xmm2, 32*68(ts) |
| 337 |
movss %xmm4, 32*12(ts) |
| 338 |
|
| 339 |
#ifdef IS_MSABI |
| 340 |
movaps (%rsp), %xmm6 |
| 341 |
movaps 16(%rsp), %xmm7 |
| 342 |
movaps 32(%rsp), %xmm8 |
| 343 |
movaps 48(%rsp), %xmm9 |
| 344 |
movaps 64(%rsp), %xmm10 |
| 345 |
movaps 80(%rsp), %xmm11 |
| 346 |
movaps 96(%rsp), %xmm12 |
| 347 |
movaps 112(%rsp), %xmm13 |
| 348 |
movaps 128(%rsp), %xmm14 |
| 349 |
movaps 144(%rsp), %xmm15 |
| 350 |
mov %rbp, %rsp |
| 351 |
pop %rbp |
| 352 |
#endif |
| 353 |
ret |
| 354 |
|
| 355 |
NONEXEC_STACK |