mirror of
https://github.com/golang/go.git
synced 2026-04-03 17:59:55 +09:00
cmd/compile: avoid panic in ternary rewrite on checked instructions
The replace function in rewritetern.go was panicing when encountering instructions that had already been processed. This adds a check to ensure we don't trigger a panic on these instructions. Fixes #77582 Change-Id: I0b38312109b9cedaa1cb1320015097d62588a2fe Reviewed-on: https://go-review.googlesource.com/c/go/+/745460 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
This commit is contained in:
29
src/cmd/compile/internal/ssa/issue77582_test.go
Normal file
29
src/cmd/compile/internal/ssa/issue77582_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2026 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.
|
||||
|
||||
//go:build goexperiment.simd && amd64
|
||||
|
||||
package ssa
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cmd/compile/internal/archsimd"
|
||||
)
|
||||
|
||||
func TestVPTERNLOGDPanic(t *testing.T) {
|
||||
if !archsimd.X86.AVX512() {
|
||||
t.Skip("Test only applies to AVX512")
|
||||
}
|
||||
|
||||
resultsMask := archsimd.Mask64x8{}
|
||||
a := archsimd.Mask64x8FromBits(0xFF)
|
||||
b := archsimd.Float64x8{}.Less(archsimd.Float64x8{})
|
||||
|
||||
for i := 0; i < 1; i++ {
|
||||
resultsMask = a.Or(b).Or(resultsMask)
|
||||
// This nested logic triggered the panic
|
||||
_ = resultsMask.And(resultsMask.And(archsimd.Mask64x8{}))
|
||||
}
|
||||
}
|
||||
@@ -174,6 +174,9 @@ func rewriteTern(f *Func) {
|
||||
replace := func(a0 *Value, vars0 [3]*Value) {
|
||||
imm := computeTT(a0, vars0)
|
||||
op := ternOpForLogical(a0.Op)
|
||||
if a0.Op >= OpAMD64LoweredGetClosurePtr {
|
||||
return // It is already an AMD64 machine instruction
|
||||
}
|
||||
if op == a0.Op {
|
||||
panic(fmt.Errorf("should have mapped away from input op, a0 is %s", a0.LongString()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user