Source file test/codegen/simd_equal.go

     1  // asmcheck
     2  
     3  // Copyright 2026 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // These tests check code generation of == and != on 128-bit SIMD vectors and
     8  // masks, which every architecture has.
     9  
    10  //go:build goexperiment.simd
    11  
    12  package codegen
    13  
    14  import "simd/archsimd"
    15  
    16  // Integer vectors and masks are equal if their XOR is zero.
    17  
    18  func eqInt32x4(x, y archsimd.Int32x4) bool {
    19  	// amd64:`VPXOR` `VPTEST` `SETEQ` -`CALL`
    20  	// arm64:`VEOR` `VUMAXV` -`CALL`
    21  	// wasm:`V128Xor` `V128AnyTrue` `I64Eqz` -`CALL`
    22  	return x == y
    23  }
    24  
    25  func neUint8x16(x, y archsimd.Uint8x16) bool {
    26  	// amd64:`VPXOR` `VPTEST` `SETNE` -`CALL`
    27  	// arm64:`VEOR` `VUMAXV` -`CALL`
    28  	// wasm:`V128Xor` `V128AnyTrue` -`CALL`
    29  	return x != y
    30  }
    31  
    32  func eqMask64x2(x, y archsimd.Mask64x2) bool {
    33  	// amd64:`VPXOR` `VPTEST` `SETEQ` -`CALL`
    34  	// arm64:`VEOR` `VUMAXV` -`CALL`
    35  	// wasm:`V128Xor` `V128AnyTrue` `I64Eqz` -`CALL`
    36  	return x == y
    37  }
    38  
    39  // Float vectors are equal if no element compares not-equal.
    40  
    41  func eqFloat32x4(x, y archsimd.Float32x4) bool {
    42  	// amd64:`VCMPPS` `VPTEST` `SETEQ` -`CALL`
    43  	// arm64:`VFCMEQ` `VNOT` `VUMAXV` -`CALL`
    44  	// wasm:`F32x4Ne` `V128AnyTrue` `I64Eqz` -`CALL`
    45  	return x == y
    46  }
    47  
    48  func neFloat64x2(x, y archsimd.Float64x2) bool {
    49  	// amd64:`VCMPPD` `VPTEST` `SETNE` -`CALL`
    50  	// arm64:`VFCMEQ` `VNOT` `VUMAXV` -`CALL`
    51  	// wasm:`F64x2Ne` `V128AnyTrue` -`CALL`
    52  	return x != y
    53  }
    54  

View as plain text