// by the compiler except for the space that they reserve.
func simdify(st *Type, isTag bool) {
st.align = 8
- st.alg = AMEM
+ st.alg = ANOALG // not comparable with ==
st.intRegs = 0
st.isSIMD = true
if isTag {
{{define "sizeTmpl"}}
// v{{.}} is a tag type that tells the compiler that this is really {{.}}-bit SIMD
type v{{.}} struct {
- _{{.}} struct{}
+ _{{.}} [0]func() // uncomparable
}
{{end}}
}
}
+func TestUncomparable(t *testing.T) {
+ // Test that simd vectors are not comparable
+ var x, y any = simd.LoadUint32x4(&[4]uint32{1, 2, 3, 4}), simd.LoadUint32x4(&[4]uint32{5, 6, 7, 8})
+ shouldPanic := func(fn func()) {
+ defer func() {
+ if recover() == nil {
+ panic("did not panic")
+ }
+ }()
+ fn()
+ }
+ shouldPanic(func() { _ = x == y })
+}
+
func TestFuncValue(t *testing.T) {
// Test that simd intrinsic can be used as a function value.
xv := [4]int32{1, 2, 3, 4}
// v128 is a tag type that tells the compiler that this is really 128-bit SIMD
type v128 struct {
- _128 struct{}
+ _128 [0]func() // uncomparable
}
// Float32x4 is a 128-bit SIMD vector of 4 float32
// v256 is a tag type that tells the compiler that this is really 256-bit SIMD
type v256 struct {
- _256 struct{}
+ _256 [0]func() // uncomparable
}
// Float32x8 is a 256-bit SIMD vector of 8 float32
// v512 is a tag type that tells the compiler that this is really 512-bit SIMD
type v512 struct {
- _512 struct{}
+ _512 [0]func() // uncomparable
}
// Float32x16 is a 512-bit SIMD vector of 16 float32