Commit 3424cf214c for golang

commit 3424cf214c19e4ae7eeffa97edba115858c04b10
Author: s-celles <s.celles@gmail.com>
Date:   Mon Nov 2 20:45:40 2026 +0100

    cmd/compile: type Power10 ReverseBytes16 as uint16, not uint

    The Power10 ReverseBytes16 intrinsic builds OpBswap16 with result type
    types.Types[types.TUINT] (64-bit unsigned); the loong64 and riscv64
    intrinsics for the same function use types.Types[types.TUINT16]. The
    value is a 16-bit byte reversal typed as a 64-bit unsigned, so the prove
    pass derives a false fact about ^int16(bits.ReverseBytes16(k)) and folds
    a comparison to the wrong result: a selected value is miscomputed on
    GOPPC64=power10 (go1.27 regression; power9 and earlier releases correct).

    Type the Power10 OpBswap16 as TUINT16, matching loong64 and riscv64.

    Add a direct exhaustive test of ReverseBytes16 alongside the original
    conditional-selection regression test.

    Fixes #82782.

    Change-Id: I4b11828bf5be18eec82524a415cd7257426ccfd6
    Assisted-by: AI
    Reviewed-on: https://go-review.googlesource.com/c/go/+/857542
    Auto-Submit: Keith Randall <khr@golang.org>
    LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
    Reviewed-by: Keith Randall <khr@google.com>
    Reviewed-by: Keith Randall <khr@golang.org>
    Reviewed-by: Robert Griesemer <gri@google.com>

diff --git a/src/cmd/compile/internal/ssagen/intrinsics.go b/src/cmd/compile/internal/ssagen/intrinsics.go
index 9061292ad7..c145696551 100644
--- a/src/cmd/compile/internal/ssagen/intrinsics.go
+++ b/src/cmd/compile/internal/ssagen/intrinsics.go
@@ -1067,7 +1067,7 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
 		// On Power10, 16-bit rotate is not available so use BRH instruction
 		addF("math/bits", "ReverseBytes16",
 			func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-				return s.newValue1(ssaop.OpBswap16, types.Types[types.TUINT], args[0])
+				return s.newValue1(ssaop.OpBswap16, types.Types[types.TUINT16], args[0])
 			},
 			sys.PPC64)
 	}
diff --git a/test/fixedbugs/issue82782.go b/test/fixedbugs/issue82782.go
new file mode 100644
index 0000000000..166bc6e7ec
--- /dev/null
+++ b/test/fixedbugs/issue82782.go
@@ -0,0 +1,41 @@
+// run
+
+// 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.
+
+package main
+
+import (
+	"fmt"
+	"math/bits"
+)
+
+//go:noinline
+func reverseBytes16(x uint16) uint16 {
+	return bits.ReverseBytes16(x)
+}
+
+//go:noinline
+func f(k uint16, y, z int16) int16 {
+	r := ^int16(bits.ReverseBytes16(k))
+	if y <= z {
+		r = 7
+	}
+	return r
+}
+
+func main() {
+	for x := uint32(0); x < 1<<16; x++ {
+		want := uint16(x<<8 | x>>8)
+		if got := reverseBytes16(uint16(x)); got != want {
+			fmt.Printf("ReverseBytes16(%#04x) = %#04x, want %#04x\n", x, got, want)
+			panic("FAIL")
+		}
+	}
+
+	if got := f(0x0400, 5, 1); got != -5 {
+		fmt.Printf("f(0x0400, 5, 1) = %d, want -5\n", got)
+		panic("FAIL")
+	}
+}