github.com/benz9527/xboot@v0.0.0-20240504061247-c23f15593274/lib/kv/fast_hash_match.s (about) 1 // Code generated by command: go run asm.go -out fast_hash_match.s -stubs fast_hash_match_amd64.go. DO NOT EDIT. 2 3 //go:build amd64 && !nosimd 4 5 #include "textflag.h" 6 7 // func Fast16WayHashMatch(md *[16]int8, hash int8) uint16 8 // Requires: SSE2, SSSE3 9 TEXT ·Fast16WayHashMatch(SB), NOSPLIT, $0-18 10 // Move the pointer of md to register AX 11 MOVQ md+0(FP), AX 12 13 // Move the hash value (int8) from mem to register CX then extend the size to int32 14 MOVBLSX hash+8(FP), CX 15 16 // Copy hash value from register CX to XMM register X0 17 // XMM registers are used by SSE or AVX instructions 18 MOVD CX, X0 19 20 // Clear the XMM register X1 21 PXOR X1, X1 22 23 // Packed Shuffle Bytes instruction, let hash value in register X0 xor with X1 by byte to generate mask to X0 24 PSHUFB X1, X0 25 26 // Load the metadata from memory to register X1 27 // (AX) means de-reference of address value in AX 28 MOVOU (AX), X1 29 30 // Packed Compare for Equal Byte instruction, compare X1 and X0 by byte then store into X0 31 // The same byte are 0xFF. Otherwise, they are 0x00 32 PCMPEQB X1, X0 33 34 // Packed Move with Mask Signed Byte, Extract X0 hi part and convert into int16 then store into AX 35 // The X0 lo part is unused usually 36 // Now the each bit of AX mapping to the each hash of metadata array whether equals to target 37 PMOVMSKB X0, AX 38 39 // Copy the AX value to mem then return 40 MOVW AX, ret+16(FP) 41 RET