From d4cb61e470a378cafbc49ff67beeea115fedec23 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 29 Dec 2021 14:49:20 +0300 Subject: [PATCH] Replace two shifts with a single AND We need to isolate HSB in every quad-word, this can be done with a simple mask. Signed-off-by: Evgenii Stratonikov --- tz/avx2_amd64.s | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tz/avx2_amd64.s b/tz/avx2_amd64.s index 787dfc7..8cbdd2e 100644 --- a/tz/avx2_amd64.s +++ b/tz/avx2_amd64.s @@ -10,8 +10,7 @@ VPALIGNR $8, Y1, Y0, Y2 \ VPSRLQ $63, Y2, Y2 \ VPXOR Y1, Y2, Y2 \ - VPSRLQ $63, Y1, Y3 \ - VPSLLQ $63, Y3, Y3 \ + VPAND Y1, Y14, Y3 \ VPUNPCKHQDQ Y3, Y3, Y3 \ VPXOR Y2, Y3, Y3 \ mask(bit, Y11, Y2) \ @@ -28,8 +27,10 @@ TEXT ·mulByteRightx2(SB),NOSPLIT,$0 VMOVDQU (BX), Y8 VPXOR Y13, Y13, Y13 // Y13 = 0x0000... - VPCMPEQB Y12, Y12, Y12 // Y12 = 0xFFFF... - VPSUBW Y12, Y13, Y12 // Y12 = 0x00010001... (packed words of 1) + VPCMPEQB Y14, Y14, Y14 // Y14 = 0xFFFF... + VPSUBQ Y14, Y13, Y10 + VPSUBW Y14, Y13, Y12 // Y12 = 0x00010001... (packed words of 1) + VPSLLQ $63, Y10, Y14 // Y14 = 0x10000000... (packed quad-words with HSB set) VPBROADCASTB b+16(FP), X10 // X10 = packed bytes of b. VPMOVZXBW X10, Y10 // Extend with zeroes to packed words.