aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorJunyang Shao <shaojunyang@google.com>2025-09-16 03:27:41 +0000
committerCherry Mui <cherryyz@google.com>2025-10-03 12:30:50 -0700
commitad3db2562edf23cb4fb9a909ea11d57b65e304fb (patch)
tree0fdb8c32f0f69b168f7ee3965ddf99bfd4724704 /src/cmd/compile
parent18cd4a1fc7d5387ae91ffc23328e4fc81f93681d (diff)
downloadgo-ad3db2562edf23cb4fb9a909ea11d57b65e304fb.tar.xz
cmd/compile: handle rematerialized op for incompatible reg constraint
This CL fixes an issue raised by contributor dominikh@. Cherry-picked from the dev.simd branch. This CL is not necessarily SIMD specific. Apply early to reduce risk. Test is SIMD specific so not included for now. Change-Id: I941b330a6ba6f6c120c69951ddd24933f2f0b3ec Reviewed-on: https://go-review.googlesource.com/c/go/+/704056 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/708861
Diffstat (limited to 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/ssa/regalloc.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go
index 26c742d7fe..88861dfa14 100644
--- a/src/cmd/compile/internal/ssa/regalloc.go
+++ b/src/cmd/compile/internal/ssa/regalloc.go
@@ -2561,7 +2561,26 @@ func (e *edgeState) processDest(loc Location, vid ID, splice **Value, pos src.XP
e.s.f.Fatalf("can't find source for %s->%s: %s\n", e.p, e.b, v.LongString())
}
if dstReg {
- x = v.copyInto(e.p)
+ // Handle incompatible registers.
+ // For #70451.
+ if e.s.regspec(v).outputs[0].regs&regMask(1<<register(loc.(*Register).num)) == 0 && c != nil {
+ _, srcReg := src.(*Register)
+ if !srcReg {
+ // We need a tmp register
+ x = v.copyInto(e.p)
+ r := e.findRegFor(x.Type)
+ e.erase(r)
+ // Rematerialize to a tmp register
+ e.set(r, vid, x, false, pos)
+ // Copy from tmp to the desired register
+ x = e.p.NewValue1(pos, OpCopy, x.Type, x)
+ } else {
+ // It exist in a valid register already, so just copy it to the desired register
+ x = e.p.NewValue1(pos, OpCopy, c.Type, c)
+ }
+ } else {
+ x = v.copyInto(e.p)
+ }
} else {
// Rematerialize into stack slot. Need a free
// register to accomplish this.