go source for verification 2026-05-22

This commit is contained in:
2026-05-22 16:44:48 +08:00
commit 3ae432d492
14992 changed files with 3674967 additions and 0 deletions

81
test/simd/bug1.go Normal file
View File

@@ -0,0 +1,81 @@
// compile
//go:build amd64 && goexperiment.simd
// 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.
// Test case for ICE on picking the wrong type for the spill slot.
package p
import (
"simd/archsimd"
"unsafe"
)
func F(
dst *[2][4][4]float32,
tos *[2][4][4]float32,
blend int,
) {
tiny := archsimd.BroadcastFloat32x8(0)
for {
dstCol12 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][0:]))))
dstCol34 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][2:]))))
dstCol56 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][0:]))))
dstCol78 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][2:]))))
tosCol12 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[0][0:]))))
tosCol34 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[0][2:]))))
tosCol56 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[1][0:]))))
tosCol78 := archsimd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[1][2:]))))
var Cr0, Cr1, Cr2 archsimd.Float32x8
if blend != 0 {
invas := tosCol78.Max(tiny)
invad := dstCol78.Max(tiny)
Cd0 := dstCol12.Mul(invad)
Cd1 := dstCol34.Mul(invad)
Cd2 := dstCol56.Mul(invad)
Cs0 := tosCol12.Mul(invas)
Cs1 := tosCol34.Mul(invas)
Cs2 := tosCol56.Mul(invas)
var Cm0, Cm1, Cm2 archsimd.Float32x8
switch blend {
case 4:
case 10:
case 11:
case 8:
case 5:
case 1:
case 0:
Cm1 = Cs1
case 2:
Cm0 = Cd0.Add(Cs0)
Cm1 = Cd1.Add(Cs1)
Cm2 = Cd2.Add(Cs2)
}
Cr0 = dstCol78.Mul(Cs0).Mul(Cm0)
Cr1 = dstCol78.Mul(Cs1).Mul(Cm1)
Cr2 = dstCol78.Mul(Cs2).Mul(Cm2)
}
var resR, resG, resB, resA archsimd.Float32x8
if blend == 0 {
resR = tosCol12
resG = tosCol34
resB = tosCol56
resA = tosCol78
} else {
resR = Cr0.Add(dstCol12)
resG = Cr1.Add(dstCol34)
resB = Cr2.Add(dstCol56)
}
resR.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][0:2]))))
resG.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][2:4]))))
resB.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][0:2]))))
resA.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][2:4]))))
}
}

69
test/simd/bug2.go Normal file
View File

@@ -0,0 +1,69 @@
// compile
//go:build amd64 && goexperiment.simd
// 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.
// Test case for rematerialization ignoring the register constraint
// during regalloc's shuffle phase.
package p
import (
"simd/archsimd"
)
func PackComplex(b bool) {
for {
if b {
var indices [4]uint32
archsimd.Uint32x4{}.ShiftAllRight(20).Store(&indices)
_ = indices[indices[0]]
}
}
}
func PackComplex2(x0 uint16, src [][4]float32, b, b2 bool) {
var out [][4]byte
if b2 {
for y := range x0 {
row := out[:x0]
for x := range row {
px := &src[y]
if b {
var indices [4]uint32
fu := archsimd.LoadFloat32x4(px).AsUint32x4()
fu.ShiftAllRight(0).Store(nil)
entry := archsimd.LoadUint32x4(&[4]uint32{
toSrgbTable[indices[0]],
})
var res [4]uint32
entry.ShiftAllRight(19).Store(nil)
row[x] = [4]uint8{
uint8(res[0]),
uint8(res[1]),
uint8(res[2]),
}
} else {
row[x] = [4]uint8{
float32ToSrgb8(0),
float32ToSrgb8(1),
float32ToSrgb8(2),
}
}
}
out = out[len(out):]
}
}
}
var toSrgbTable = [4]uint32{}
func float32ToSrgb8(f float32) uint8 {
f = min(0, f)
fu := uint32(f)
entry := toSrgbTable[fu]
return uint8(entry * fu)
}