diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go
index 6f21432..6c991bd 100644
--- a/src/cmd/compile/internal/ssa/prove.go
+++ b/src/cmd/compile/internal/ssa/prove.go
@@ -2742,7 +2742,7 @@
// if x is larger than -y (y is negative), then slicemask is -1.
lim := ft.limits[x.ID]
if lim.umin > uint64(-delta) {
- if cap.Op == OpAdd64 {
+ if cap.Type.Size() == 8 {
v.reset(OpConst64)
} else {
v.reset(OpConst32)
diff --git a/test/fixedbugs/issue79874.go b/test/fixedbugs/issue79874.go
new file mode 100644
index 0000000..50059ab
--- /dev/null
+++ b/test/fixedbugs/issue79874.go
@@ -0,0 +1,28 @@
+// run
+
+//go:build unix && !(386 || arm || mips || mipsle)
+
+package main
+
+import (
+ "encoding/binary"
+ "fmt"
+)
+
+const l = 1 << 34
+
+//go:noinline
+func bug(s []byte) []byte {
+ if len(s) < l+8 {
+ panic("too short")
+ }
+ return s[min(l, len(s)):]
+}
+
+func main() {
+ s := make([]byte, l+8)
+ binary.LittleEndian.PutUint64(s[l:], l)
+ if v := binary.LittleEndian.Uint64(bug(s)); v != l {
+ panic(fmt.Sprintf("got %d, want %d", v, l))
+ }
+}