[go] cmd/compile: avoid folding 64-bit integers into 32-bit constants

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Feb 14, 2026, 3:18:05 PMFeb 14
to Youlin Feng, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Dmitri Shuralyov, Dmitri Shuralyov, Keith Randall, Keith Randall, Go LUCI, Martin Möhrmann, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
cmd/compile: avoid folding 64-bit integers into 32-bit constants

Folding a 64-bit integer into a 32-bit constant may result in a negative
integer if the value exceeds math.MaxInt32 (the maximum value of a 32-
bit signed integer). This negative value will be sign-extended to 64
bits at runtime, leading to unexpected results when used in bitwise
AND/OR operations.

Fixes #77613
Change-Id: Idb081a3c20c28bddddcc8eff1225d62123b37a2d
Auto-Submit: Keith Randall <k...@golang.org>
Reviewed-by: Keith Randall <k...@google.com>
Reviewed-by: Keith Randall <k...@golang.org>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
Files:
  • M src/cmd/compile/internal/ssa/_gen/AMD64.rules
  • M src/cmd/compile/internal/ssa/rewriteAMD64.go
  • A test/fixedbugs/issue77613.go
Change size: M
Delta: 3 files changed, 48 insertions(+), 4 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Keith Randall, +1 by Keith Randall, +1 by Dmitri Shuralyov
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Idb081a3c20c28bddddcc8eff1225d62123b37a2d
Gerrit-Change-Number: 745581
Gerrit-PatchSet: 3
Gerrit-Owner: Youlin Feng <fengy...@live.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Martin Möhrmann <moeh...@google.com>
Gerrit-Reviewer: Youlin Feng <fengy...@live.com>
Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages