go/test/codegen/simd.go
Junyang Shao 578777bf7c [dev.simd] cmd/compile: make condtion of CanSSA smarter for SIMD fields
This CL tires to improve a situation pointed out by
https://github.com/golang/go/issues/73787#issuecomment-3305494947.

Change-Id: Ic23c80fe71344fc25383ab238ad6631e0f0cd22e
Reviewed-on: https://go-review.googlesource.com/c/go/+/705416
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-26 10:53:39 -07:00

59 lines
1.2 KiB
Go

// asmcheck
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// These tests check code generation of simd peephole optimizations.
//go:build goexperiment.simd
package codegen
import "simd"
func vptest1() bool {
v1 := simd.LoadUint64x2Slice([]uint64{0, 1})
v2 := simd.LoadUint64x2Slice([]uint64{0, 0})
// amd64:`VPTEST\s(.*)(.*)$`
// amd64:`SETCS\s(.*)$`
return v1.AndNot(v2).IsZero()
}
func vptest2() bool {
v1 := simd.LoadUint64x2Slice([]uint64{0, 1})
v2 := simd.LoadUint64x2Slice([]uint64{0, 0})
// amd64:`VPTEST\s(.*)(.*)$`
// amd64:`SETEQ\s(.*)$`
return v1.And(v2).IsZero()
}
type Args2 struct {
V0 simd.Uint8x32
V1 simd.Uint8x32
x string
}
//go:noinline
func simdStructNoSpill(a Args2) simd.Uint8x32 {
// amd64:-`VMOVDQU\s.*$`
return a.V0.Xor(a.V1)
}
func simdStructWrapperNoSpill(a Args2) simd.Uint8x32 {
// amd64:-`VMOVDQU\s.*$`
a.x = "test"
return simdStructNoSpill(a)
}
//go:noinline
func simdArrayNoSpill(a [1]Args2) simd.Uint8x32 {
// amd64:-`VMOVDQU\s.*$`
return a[0].V0.Xor(a[0].V1)
}
func simdArrayWrapperNoSpill(a [1]Args2) simd.Uint8x32 {
// amd64:-`VMOVDQU\s.*$`
a[0].x = "test"
return simdArrayNoSpill(a)
}