Skip to content

Commit ad3db25

Browse files
JunyangShaocherrymui
authored andcommitted
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 <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/go/+/708861
1 parent 18cd4a1 commit ad3db25

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/cmd/compile/internal/ssa/regalloc.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2561,7 +2561,26 @@ func (e *edgeState) processDest(loc Location, vid ID, splice **Value, pos src.XP
25612561
e.s.f.Fatalf("can't find source for %s->%s: %s\n", e.p, e.b, v.LongString())
25622562
}
25632563
if dstReg {
2564-
x = v.copyInto(e.p)
2564+
// Handle incompatible registers.
2565+
// For #70451.
2566+
if e.s.regspec(v).outputs[0].regs&regMask(1<<register(loc.(*Register).num)) == 0 && c != nil {
2567+
_, srcReg := src.(*Register)
2568+
if !srcReg {
2569+
// We need a tmp register
2570+
x = v.copyInto(e.p)
2571+
r := e.findRegFor(x.Type)
2572+
e.erase(r)
2573+
// Rematerialize to a tmp register
2574+
e.set(r, vid, x, false, pos)
2575+
// Copy from tmp to the desired register
2576+
x = e.p.NewValue1(pos, OpCopy, x.Type, x)
2577+
} else {
2578+
// It exist in a valid register already, so just copy it to the desired register
2579+
x = e.p.NewValue1(pos, OpCopy, c.Type, c)
2580+
}
2581+
} else {
2582+
x = v.copyInto(e.p)
2583+
}
25652584
} else {
25662585
// Rematerialize into stack slot. Need a free
25672586
// register to accomplish this.

0 commit comments

Comments
 (0)