[go] cmd/compile: do not home mul/div results in HI/LO

2 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jul 25, 2026, 9:25:02 AM (yesterday) Jul 25
to Jorropo, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, David Chase, Daniel McCarney, Keith Randall, Keith Randall, golang...@luci-project-accounts.iam.gserviceaccount.com, Martin Möhrmann, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
cmd/compile: do not home mul/div results in HI/LO

On mips and mips64, multiply/divide results were tuple outputs in the
special HI/LO registers, and regalloc kept live values homed there.
Spilling such a value must route the data through REGTMP (there is no
direct store from HI/LO). When the stack frame is too large for a
16-bit offset, the assembler also materializes the spill slot address
in REGTMP:

MOVV LO, R23
LUI R23, $1
DADDU R23, R23, SP
SD R23, off(R23)

clobbering the value and silently storing SP+0x10000 instead.

Instead, make MULV/MULVU/DIVV/DIVVU (mips64) and MULT/MULTU/DIV/DIVU
(mips) produce their results in two general registers, moving out of
HI and LO as part of the op itself.

Since register-register moves do not depend on REGTMP it can't get
the dual use bug.

Fixes #80563
Change-Id: I2a0cb5ec7103ab2b0cbbeb67edd38ff5cb33bf77
Reviewed-by: Keith Randall <k...@golang.org>
Reviewed-by: Keith Randall <k...@google.com>
Reviewed-by: David Chase <drc...@google.com>
Auto-Submit: Jorropo <jorro...@gmail.com>
Files:
  • M src/cmd/compile/internal/mips/ssa.go
  • M src/cmd/compile/internal/mips64/ssa.go
  • M src/cmd/compile/internal/ssa/_gen/MIPS64Ops.go
  • M src/cmd/compile/internal/ssa/_gen/MIPSOps.go
  • M src/cmd/compile/internal/ssa/opGen.go
  • M src/cmd/internal/obj/mips/asm0.go
Change size: M
Delta: 6 files changed, 107 insertions(+), 62 deletions(-)
Branch: refs/heads/master
Submit Requirements:
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: I2a0cb5ec7103ab2b0cbbeb67edd38ff5cb33bf77
Gerrit-Change-Number: 805420
Gerrit-PatchSet: 2
Gerrit-Owner: Jorropo <jorro...@gmail.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Martin Möhrmann <moeh...@google.com>
Gerrit-CC: Daniel McCarney <dan...@binaryparadox.net>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages