diff options
| author | David Chase <drchase@google.com> | 2026-02-25 15:56:36 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-26 07:22:41 -0700 |
| commit | 82b95c14ec9ef72c725841d1984a4d70e060899e (patch) | |
| tree | d90b2e46ae4ebab229f3bf3f1035df7f1365a89c | |
| parent | f14d3a8e91ac6d9fa2071f58be4ffb817519a278 (diff) | |
| download | go-82b95c14ec9ef72c725841d1984a4d70e060899e.tar.xz | |
[release-branch.go1.26] 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 #77773.
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>
(cherry picked from commit 89d92fc21166c27db7d4203d93019e33f8cb9695)
Reviewed-on: https://go-review.googlesource.com/c/go/+/750860
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
| -rw-r--r-- | src/cmd/compile/internal/ssa/rewritetern.go | 6 | ||||
| -rw-r--r-- | test/simd.go | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/rewritetern.go b/src/cmd/compile/internal/ssa/rewritetern.go index 5493e5f109..766b3f898c 100644 --- a/src/cmd/compile/internal/ssa/rewritetern.go +++ b/src/cmd/compile/internal/ssa/rewritetern.go @@ -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, diff --git a/test/simd.go b/test/simd.go index 52e5ad6c21..05cc24f3a9 100644 --- a/test/simd.go +++ b/test/simd.go @@ -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{}))) + } +} |
