Use vzeroall to clear scratch registers
When clearing scratch registers on Linux,
all XMM and YMM registers can be cleared using
vzeroall. On AVX512, this instruction can be used
to clear the first 16 ZMM registers too.
;
%macro clear_scratch_xmms_avx_asm 0
%ifdef LINUX
-%assign i 0
-%rep 16
- vpxor xmm %+ i, xmm %+ i
-%assign i (i+1)
-%endrep
+ vzeroall
; On Windows, XMM0-XMM5 registers are scratch registers
%else
%assign i 0
%macro clear_scratch_ymms_asm 0
; On Linux, all YMM registers are scratch registers
%ifdef LINUX
-%assign i 0
-%rep 16
- vpxor ymm %+ i, ymm %+ i
-%assign i (i+1)
-%endrep
+ vzeroall
; On Windows, YMM0-YMM5 registers are scratch registers.
; YMM6-YMM15 upper 128 bits are scratch registers too, but
; the lower 128 bits are to be restored after calling these function
%macro clear_scratch_zmms_asm 0
; On Linux, all ZMM registers are scratch registers
%ifdef LINUX
-%assign i 0
-%rep 32
+ vzeroall
+ ;; vzeroall only clears the first 16 ZMM registers
+%assign i 16
+%rep 16
vpxorq ymm %+ i, ymm %+ i
%assign i (i+1)
%endrep
