📄 dot_sse.s
字号:
/*********************************************************************//* *//* Optimized BLAS libraries *//* By Kazushige Goto <kgoto@tacc.utexas.edu> *//* *//* Copyright (c) The University of Texas, 2005. All rights reserved. *//* UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING *//* THIS SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF *//* MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, *//* NON-INFRINGEMENT AND WARRANTIES OF PERFORMANCE, AND ANY WARRANTY *//* THAT MIGHT OTHERWISE ARISE FROM COURSE OF DEALING OR USAGE OF *//* TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH RESPECT TO *//* THE USE OF THE SOFTWARE OR DOCUMENTATION. *//* Under no circumstances shall University be liable for incidental, *//* special, indirect, direct or consequential damages or loss of *//* profits, interruption of business, or related expenses which may *//* arise from use of Software or Documentation, including but not *//* limited to those resulting from defects in Software and/or *//* Documentation, or loss or inaccuracy of data of any kind. *//*********************************************************************/#define ASSEMBLER#include "common.h"#define N ARG1 /* rdi */#define X ARG2 /* rsi */#define INCX ARG3 /* rdx */#define Y ARG4 /* rcx */#ifndef WINDOWS_ABI#define INCY ARG5 /* r8 */#else#define INCY %r10#endif PROLOGUE PROFCODE#ifdef WINDOWS_ABI movq 40(%rsp), INCY#endif SAVEREGISTERS#ifdef F_INTERFACE#ifndef USE64BITINT movslq (N), N # N movslq (INCX),INCX # INCX movslq (INCY),INCY # INCY#else movq (N), N # N movq (INCX),INCX # INCX movq (INCY),INCY # INCY#endif#endif leaq (, INCX, SIZE), INCX leaq (, INCY, SIZE), INCY pxor %xmm0, %xmm0 pxor %xmm1, %xmm1 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 cmpq $0, N jle .L999 cmpq $SIZE, INCX jne .L50 cmpq $SIZE, INCY jne .L50 cmpq $3, N jle .L17 testq $SIZE, Y je .L05 movss 0 * SIZE(X), %xmm0 mulss 0 * SIZE(Y), %xmm0 addq $1 * SIZE, X addq $1 * SIZE, Y decq N ALIGN_2.L05: testq $2 * SIZE, Y je .L10 movsd 0 * SIZE(X), %xmm4 movsd 0 * SIZE(Y), %xmm1 mulps %xmm4, %xmm1 addq $2 * SIZE, X addq $2 * SIZE, Y subq $2, N jle .L999 ALIGN_2.L10: testq $3 * SIZE, X jne .L20 movq N, %rax sarq $5, %rax jle .L14 movaps 0 * SIZE(X), %xmm4 movaps 4 * SIZE(X), %xmm5 movaps 8 * SIZE(X), %xmm6 movaps 12 * SIZE(X), %xmm7 movaps 0 * SIZE(Y), %xmm8 movaps 4 * SIZE(Y), %xmm9 movaps 8 * SIZE(Y), %xmm10 movaps 12 * SIZE(Y), %xmm11 movaps 16 * SIZE(X), %xmm12 movaps 20 * SIZE(X), %xmm13 movaps 24 * SIZE(X), %xmm14 movaps 28 * SIZE(X), %xmm15 mulps %xmm8, %xmm4 movaps 16 * SIZE(Y), %xmm8 mulps %xmm9, %xmm5 movaps 20 * SIZE(Y), %xmm9 mulps %xmm10, %xmm6 movaps 24 * SIZE(Y), %xmm10 mulps %xmm11, %xmm7 movaps 28 * SIZE(Y), %xmm11 decq %rax jle .L12 ALIGN_3.L11: addps %xmm4, %xmm0 movaps 32 * SIZE(X), %xmm4 mulps %xmm8, %xmm12 addps %xmm5, %xmm1 movaps 36 * SIZE(X), %xmm5 mulps %xmm9, %xmm13 addps %xmm6, %xmm2 movaps 40 * SIZE(X), %xmm6 mulps %xmm10, %xmm14 addps %xmm7, %xmm3 movaps 44 * SIZE(X), %xmm7 mulps %xmm11, %xmm15 movaps 32 * SIZE(Y), %xmm8 movaps 36 * SIZE(Y), %xmm9 movaps 40 * SIZE(Y), %xmm10 movaps 44 * SIZE(Y), %xmm11 addps %xmm12, %xmm0 movaps 48 * SIZE(X), %xmm12 mulps %xmm8, %xmm4 addps %xmm13, %xmm1 movaps 52 * SIZE(X), %xmm13 mulps %xmm9, %xmm5 addps %xmm14, %xmm2 movaps 56 * SIZE(X), %xmm14 mulps %xmm10, %xmm6 addps %xmm15, %xmm3 movaps 60 * SIZE(X), %xmm15 mulps %xmm11, %xmm7 movaps 48 * SIZE(Y), %xmm8 movaps 52 * SIZE(Y), %xmm9 movaps 56 * SIZE(Y), %xmm10 movaps 60 * SIZE(Y), %xmm11 addq $32 * SIZE, X addq $32 * SIZE, Y decq %rax jg .L11 ALIGN_3.L12: addps %xmm4, %xmm0 mulps %xmm8, %xmm12 addps %xmm5, %xmm1 mulps %xmm9, %xmm13 addps %xmm6, %xmm2 mulps %xmm10, %xmm14 addps %xmm7, %xmm3 mulps %xmm11, %xmm15 addps %xmm12, %xmm0 addps %xmm13, %xmm1 addps %xmm14, %xmm2 addps %xmm15, %xmm3 addq $32 * SIZE, X addq $32 * SIZE, Y ALIGN_3.L14: testq $31, N jle .L999 movq N, %rax andq $16, %rax jle .L15 movaps 0 * SIZE(X), %xmm4 movaps 4 * SIZE(X), %xmm5 movaps 8 * SIZE(X), %xmm6 movaps 12 * SIZE(X), %xmm7 movaps 0 * SIZE(Y), %xmm8 movaps 4 * SIZE(Y), %xmm9 movaps 8 * SIZE(Y), %xmm10 movaps 12 * SIZE(Y), %xmm11 mulps %xmm8, %xmm4 mulps %xmm9, %xmm5 mulps %xmm10, %xmm6 mulps %xmm11, %xmm7 addps %xmm4, %xmm0 addps %xmm5, %xmm1 addps %xmm6, %xmm2 addps %xmm7, %xmm3 addq $16 * SIZE, X addq $16 * SIZE, Y ALIGN_3.L15: movq N, %rax andq $8, %rax jle .L16 movaps 0 * SIZE(X), %xmm4 movaps 4 * SIZE(X), %xmm5 movaps 0 * SIZE(Y), %xmm8 movaps 4 * SIZE(Y), %xmm9 mulps %xmm8, %xmm4 mulps %xmm9, %xmm5 addps %xmm4, %xmm0 addps %xmm5, %xmm1 addq $8 * SIZE, X addq $8 * SIZE, Y ALIGN_3.L16: movq N, %rax andq $4, %rax jle .L17 movaps 0 * SIZE(X), %xmm4 movaps 0 * SIZE(Y), %xmm8 mulps %xmm8, %xmm4 addps %xmm4, %xmm2 addq $4 * SIZE, X addq $4 * SIZE, Y ALIGN_3.L17: movq N, %rax andq $2, %rax jle .L18 movsd 0 * SIZE(X), %xmm4 movsd 0 * SIZE(Y), %xmm8 mulps %xmm8, %xmm4 addps %xmm4, %xmm3 addq $2 * SIZE, X addq $2 * SIZE, Y ALIGN_3.L18: movq N, %rax andq $1, %rax jle .L999 movss 0 * SIZE(X), %xmm4 movss 0 * SIZE(Y), %xmm8 mulss %xmm8, %xmm4 addss %xmm4, %xmm0 jmp .L999 ALIGN_3.L20: movq N, %rax sarq $5, %rax jle .L24#ifdef HAVE_SSE3 lddqu 0 * SIZE(X), %xmm4 lddqu 4 * SIZE(X), %xmm5 lddqu 8 * SIZE(X), %xmm6 lddqu 12 * SIZE(X), %xmm7#else movsd 0 * SIZE(X), %xmm4 movhps 2 * SIZE(X), %xmm4 movsd 4 * SIZE(X), %xmm5 movhps 6 * SIZE(X), %xmm5 movsd 8 * SIZE(X), %xmm6 movhps 10 * SIZE(X), %xmm6 movsd 12 * SIZE(X), %xmm7 movhps 14 * SIZE(X), %xmm7#endif movaps 0 * SIZE(Y), %xmm8 movaps 4 * SIZE(Y), %xmm9 movaps 8 * SIZE(Y), %xmm10 movaps 12 * SIZE(Y), %xmm11#ifdef HAVE_SSE3 lddqu 16 * SIZE(X), %xmm12 lddqu 20 * SIZE(X), %xmm13 lddqu 24 * SIZE(X), %xmm14 lddqu 28 * SIZE(X), %xmm15#else movsd 16 * SIZE(X), %xmm12 movhps 18 * SIZE(X), %xmm12 movsd 20 * SIZE(X), %xmm13 movhps 22 * SIZE(X), %xmm13 movsd 24 * SIZE(X), %xmm14 movhps 26 * SIZE(X), %xmm14 movsd 28 * SIZE(X), %xmm15 movhps 30 * SIZE(X), %xmm15#endif mulps %xmm8, %xmm4 movaps 16 * SIZE(Y), %xmm8 mulps %xmm9, %xmm5 movaps 20 * SIZE(Y), %xmm9 mulps %xmm10, %xmm6 movaps 24 * SIZE(Y), %xmm10 mulps %xmm11, %xmm7 movaps 28 * SIZE(Y), %xmm11 decq %rax jle .L22 ALIGN_3.L21: addps %xmm4, %xmm0#ifdef HAVE_SSE3 lddqu 32 * SIZE(X), %xmm4#else movsd 32 * SIZE(X), %xmm4 movhps 34 * SIZE(X), %xmm4#endif mulps %xmm8, %xmm12 addps %xmm5, %xmm1#ifdef HAVE_SSE3 lddqu 36 * SIZE(X), %xmm5#else movsd 36 * SIZE(X), %xmm5 movhps 38 * SIZE(X), %xmm5#endif mulps %xmm9, %xmm13 addps %xmm6, %xmm2#ifdef HAVE_SSE3 lddqu 40 * SIZE(X), %xmm6#else movsd 40 * SIZE(X), %xmm6 movhps 42 * SIZE(X), %xmm6#endif mulps %xmm10, %xmm14 addps %xmm7, %xmm3#ifdef HAVE_SSE3 lddqu 44 * SIZE(X), %xmm7#else movsd 44 * SIZE(X), %xmm7 movhps 46 * SIZE(X), %xmm7#endif mulps %xmm11, %xmm15 movaps 32 * SIZE(Y), %xmm8 movaps 36 * SIZE(Y), %xmm9 movaps 40 * SIZE(Y), %xmm10 movaps 44 * SIZE(Y), %xmm11 addps %xmm12, %xmm0#ifdef HAVE_SSE3 lddqu 48 * SIZE(X), %xmm12#else movsd 48 * SIZE(X), %xmm12 movhps 50 * SIZE(X), %xmm12#endif mulps %xmm8, %xmm4 addps %xmm13, %xmm1#ifdef HAVE_SSE3 lddqu 52 * SIZE(X), %xmm13#else movsd 52 * SIZE(X), %xmm13 movhps 54 * SIZE(X), %xmm13#endif mulps %xmm9, %xmm5 addps %xmm14, %xmm2#ifdef HAVE_SSE3 lddqu 56 * SIZE(X), %xmm14#else movsd 56 * SIZE(X), %xmm14 movhps 58 * SIZE(X), %xmm14#endif mulps %xmm10, %xmm6 addps %xmm15, %xmm3#ifdef HAVE_SSE3 lddqu 60 * SIZE(X), %xmm15#else movsd 60 * SIZE(X), %xmm15 movhps 62 * SIZE(X), %xmm15#endif mulps %xmm11, %xmm7 movaps 48 * SIZE(Y), %xmm8 movaps 52 * SIZE(Y), %xmm9 movaps 56 * SIZE(Y), %xmm10 movaps 60 * SIZE(Y), %xmm11 addq $32 * SIZE, X addq $32 * SIZE, Y decq %rax jg .L21 ALIGN_3.L22: addps %xmm4, %xmm0 mulps %xmm8, %xmm12 addps %xmm5, %xmm1 mulps %xmm9, %xmm13 addps %xmm6, %xmm2 mulps %xmm10, %xmm14 addps %xmm7, %xmm3 mulps %xmm11, %xmm15 addps %xmm12, %xmm0 addps %xmm13, %xmm1 addps %xmm14, %xmm2 addps %xmm15, %xmm3 addq $32 * SIZE, X addq $32 * SIZE, Y ALIGN_3.L24: testq $31, N jle .L999 movq N, %rax andq $16, %rax jle .L25#ifdef HAVE_SSE3 lddqu 0 * SIZE(X), %xmm4 lddqu 4 * SIZE(X), %xmm5 lddqu 8 * SIZE(X), %xmm6 lddqu 12 * SIZE(X), %xmm7#else movsd 0 * SIZE(X), %xmm4 movhps 2 * SIZE(X), %xmm4 movsd 4 * SIZE(X), %xmm5 movhps 6 * SIZE(X), %xmm5 movsd 8 * SIZE(X), %xmm6 movhps 10 * SIZE(X), %xmm6 movsd 12 * SIZE(X), %xmm7 movhps 14 * SIZE(X), %xmm7#endif movaps 0 * SIZE(Y), %xmm8 movaps 4 * SIZE(Y), %xmm9 movaps 8 * SIZE(Y), %xmm10 movaps 12 * SIZE(Y), %xmm11 mulps %xmm8, %xmm4 mulps %xmm9, %xmm5 mulps %xmm10, %xmm6 mulps %xmm11, %xmm7 addps %xmm4, %xmm0 addps %xmm5, %xmm1 addps %xmm6, %xmm2 addps %xmm7, %xmm3 addq $16 * SIZE, X addq $16 * SIZE, Y ALIGN_3.L25: movq N, %rax andq $8, %rax jle .L26#ifdef HAVE_SSE3 lddqu 0 * SIZE(X), %xmm4 lddqu 4 * SIZE(X), %xmm5#else movsd 0 * SIZE(X), %xmm4 movhps 2 * SIZE(X), %xmm4 movsd 4 * SIZE(X), %xmm5 movhps 6 * SIZE(X), %xmm5#endif movaps 0 * SIZE(Y), %xmm8 movaps 4 * SIZE(Y), %xmm9 mulps %xmm8, %xmm4 mulps %xmm9, %xmm5 addps %xmm4, %xmm0 addps %xmm5, %xmm1 addq $8 * SIZE, X addq $8 * SIZE, Y ALIGN_3.L26: movq N, %rax andq $4, %rax jle .L27#ifdef HAVE_SSE3 lddqu 0 * SIZE(X), %xmm4#else movsd 0 * SIZE(X), %xmm4 movhps 2 * SIZE(X), %xmm4#endif movaps 0 * SIZE(Y), %xmm8 mulps %xmm8, %xmm4 addps %xmm4, %xmm2 addq $4 * SIZE, X addq $4 * SIZE, Y ALIGN_3.L27: movq N, %rax andq $2, %rax jle .L28 movsd 0 * SIZE(X), %xmm4 movsd 0 * SIZE(Y), %xmm8 mulps %xmm8, %xmm4 addps %xmm4, %xmm3 addq $2 * SIZE, X addq $2 * SIZE, Y ALIGN_3.L28: movq N, %rax andq $1, %rax jle .L999 movss 0 * SIZE(X), %xmm4 movss 0 * SIZE(Y), %xmm8 mulss %xmm8, %xmm4 addss %xmm4, %xmm0 jmp .L999 ALIGN_3.L50:#ifdef F_INTERFACE testq INCX, INCX jge .L51 movq N, %rax decq %rax imulq INCX, %rax subq %rax, X ALIGN_3.L51: testq INCY, INCY jge .L52 movq N, %rax decq %rax imulq INCY, %rax subq %rax, Y ALIGN_3.L52:#endif movq N, %rax sarq $2, %rax jle .L55 ALIGN_3.L53: movss 0 * SIZE(X), %xmm4 addq INCX, X mulss 0 * SIZE(Y), %xmm4 addq INCY, Y movss 0 * SIZE(X), %xmm5 addq INCX, X mulss 0 * SIZE(Y), %xmm5 addq INCY, Y movss 0 * SIZE(X), %xmm6 addq INCX, X mulss 0 * SIZE(Y), %xmm6 addq INCY, Y movss 0 * SIZE(X), %xmm7 addq INCX, X mulss 0 * SIZE(Y), %xmm7 addq INCY, Y addss %xmm4, %xmm0 addss %xmm5, %xmm1 addss %xmm6, %xmm2 addss %xmm7, %xmm3 decq %rax jg .L53 ALIGN_3.L55: movq N, %rax andq $3, %rax jle .L999 ALIGN_3.L56: movss 0 * SIZE(X), %xmm4 addq INCX, X mulss 0 * SIZE(Y), %xmm4 addq INCY, Y addss %xmm4, %xmm0 decq %rax jg .L56 ALIGN_3.L999: addps %xmm1, %xmm0 addps %xmm3, %xmm2 addps %xmm2, %xmm0#ifndef HAVE_SSE3 movhlps %xmm0, %xmm1 addps %xmm1, %xmm0 movaps %xmm0, %xmm1 shufps $1, %xmm0, %xmm0 addss %xmm1, %xmm0#else haddps %xmm0, %xmm0 haddps %xmm0, %xmm0#endif#if !defined(DOUBLE) && defined(F_INTERFACE) && defined(NEED_F2CCONV) cvtss2sd %xmm0, %xmm0#endif RESTOREREGISTERS ret EPILOGUE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -