// +build ignore package main import ( . "github.com/mmcloughlin/avo/build" . "github.com/mmcloughlin/avo/operand" ) func init() { ConstraintExpr("!purego") } func main() { TEXT("intersect16", NOSPLIT, "func(dst, a, b []byte) int") // Load all pointers. dst := Load(Param("dst").Base(), GP64()) a := Load(Param("a").Base(), GP64()) b := Load(Param("b").Base(), GP64()) // Calculate the end of a/b so we know where to loop until. aEnd := Load(Param("a").Len(), GP64()) ADDQ(a, aEnd) bEnd := Load(Param("b").Len(), GP64()) ADDQ(b, bEnd) ones := XMM() VPCMPEQB(ones, ones, ones) // Load the first item from a/b. We know that each has at least // one item (this is enforced in the wrapper). aItem := XMM() bItem := XMM() VMOVUPS(Mem{Base: a}, aItem) VMOVUPS(Mem{Base: b}, bItem) Label("loop") // Compare bytes and extract two masks. // ne = mask of bytes where a!=b // lt = mask of bytes where a