cmd/compile: ternary rewrite of rewrite should skip, not panic

The panic was unnecessary, if there's nothing to rewrite,
just do nothing.  Added a debug message for this to help
with testing; it seems (from accidentally perturbing the
test away from failure) to be somewhat rare, so likely
okay to mingle with the other debugging output.

Fixes #77582.

Change-Id: I676396f4bb530cb6b55dfe543ad489f84710900d
Reviewed-on: https://go-review.googlesource.com/c/go/+/749241
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
David Chase
2026-02-25 15:56:36 -05:00
parent b4ef60b9cb
commit 89d92fc211
2 changed files with 19 additions and 3 deletions

View File

@@ -5,7 +5,6 @@
package ssa
import (
"fmt"
"internal/goarch"
"slices"
)
@@ -175,7 +174,10 @@ func rewriteTern(f *Func) {
imm := computeTT(a0, vars0)
op := ternOpForLogical(a0.Op)
if op == a0.Op {
panic(fmt.Errorf("should have mapped away from input op, a0 is %s", a0.LongString()))
if f.pass.debug > 0 {
f.Warnl(a0.Pos, "Skipping rewrite for %s, op=%v", a0.LongString(), op)
}
return
}
if f.pass.debug > 0 {
f.Warnl(a0.Pos, "Rewriting %s into %v of 0b%b %v %v %v", a0.LongString(), op, imm,

View File

@@ -8,7 +8,10 @@
package foo
import "simd/archsimd"
import (
"fmt"
"simd/archsimd"
)
func f1(x archsimd.Int8x16) {
return // ERROR "has features avx"
@@ -143,3 +146,14 @@ func ternTricky3(x, y, z archsimd.Int32x8) archsimd.Int32x8 {
// a is a common subexpression
return a.Or(w) // ERROR "has features avx[+]avx2[+]avx512" // This does not rewrite, do we want it to?
}
func vpternlogdPanic() {
resultsMask := archsimd.Mask64x8{}
for { // ERROR "has features avx+avx2+avx512"
resultsMask = archsimd.Mask64x8FromBits(0).Or( // ERROR "has features avx+avx2+avx512"
archsimd.Float64x8{}.Less(
archsimd.BroadcastFloat64x8(0))).Or(resultsMask) // ERROR "Rewriting.*ternInt" "Skipping rewrite"
fmt.Print(resultsMask.And(resultsMask.And(archsimd.Mask64x8{})))
}
}