Skip to content

Commit 003b5ce

Browse files
JunyangShaocherrymui
authored andcommitted
cmd/compile: fix SIMD const rematerialization condition
This CL fixes a condition for the previous fix CL 704056. 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: I1f1f8c6f72870403cb3dff14755c43385dc0c933 Reviewed-on: https://go-review.googlesource.com/c/go/+/705499 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/go/+/708864 Reviewed-by: David Chase <[email protected]>
1 parent d91148c commit 003b5ce

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,22 +2561,25 @@ 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-
// Handle incompatible registers.
2564+
// We want to rematerialize v into a register that is incompatible with v's op's register mask.
2565+
// Instead of setting the wrong register for the rematerialized v, we should find the right register
2566+
// for it and emit an additional copy to move to the desired register.
25652567
// For #70451.
2566-
if e.s.regspec(v).outputs[0].regs&regMask(1<<register(loc.(*Register).num)) == 0 && c != nil {
2568+
if e.s.regspec(v).outputs[0].regs&regMask(1<<register(loc.(*Register).num)) == 0 {
25672569
_, srcReg := src.(*Register)
2568-
if !srcReg {
2570+
if srcReg {
2571+
// It exists in a valid register already, so just copy it to the desired register
2572+
// If src is a Register, c must have already been set.
2573+
x = e.p.NewValue1(pos, OpCopy, c.Type, c)
2574+
} else {
25692575
// We need a tmp register
25702576
x = v.copyInto(e.p)
25712577
r := e.findRegFor(x.Type)
25722578
e.erase(r)
2573-
// Rematerialize to a tmp register
2579+
// Rematerialize to the tmp register
25742580
e.set(r, vid, x, false, pos)
25752581
// Copy from tmp to the desired register
25762582
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)
25802583
}
25812584
} else {
25822585
x = v.copyInto(e.p)

0 commit comments

Comments
 (0)