mirror of
https://github.com/golang/go.git
synced 2025-05-24 17:01:26 +00:00
[dev.ssa] cmd/compile: don't flush a value derived from the current value
If flushing a value from a register that might be used by the current old-schedule value, save it to the home location. This resolves the error that was changed from panic to unimplemented in CL 12655. Change-Id: If864be34abcd6e11d6117a061376e048a3e29b3a Reviewed-on: https://go-review.googlesource.com/12682 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
b61f8c8df3
commit
c9a38ce758
@ -8,6 +8,8 @@
|
||||
|
||||
package main
|
||||
|
||||
// test64BitConstMulti tests that rewrite rules don't fold 64 bit constants
|
||||
// into multiply instructions.
|
||||
func test64BitConstMult(a, b int64) {
|
||||
want := 34359738369*a + b*34359738370
|
||||
if got := test64BitConstMult_ssa(a, b); want != got {
|
||||
@ -21,6 +23,8 @@ func test64BitConstMult_ssa(a, b int64) int64 {
|
||||
return 34359738369*a + b*34359738370
|
||||
}
|
||||
|
||||
// test64BitConstAdd tests that rewrite rules don't fold 64 bit constants
|
||||
// into add instructions.
|
||||
func test64BitConstAdd(a, b int64) {
|
||||
want := a + 575815584948629622 + b + 2991856197886747025
|
||||
if got := test64BitConstAdd_ssa(a, b); want != got {
|
||||
@ -34,12 +38,28 @@ func test64BitConstAdd_ssa(a, b int64) int64 {
|
||||
return a + 575815584948629622 + b + 2991856197886747025
|
||||
}
|
||||
|
||||
// testRegallocCVSpill tests that regalloc spills a value whose last use is the
|
||||
// current value.
|
||||
func testRegallocCVSpill(a, b, c, d int8) {
|
||||
want := a + -32 + b + 63*c*-87*d
|
||||
if got := testRegallocCVSpill_ssa(a, b, c, d); want != got {
|
||||
println("testRegallocCVSpill failed, wanted", want, "got", got)
|
||||
failed = true
|
||||
}
|
||||
}
|
||||
func testRegallocCVSpill_ssa(a, b, c, d int8) int8 {
|
||||
switch {
|
||||
}
|
||||
return a + -32 + b + 63*c*-87*d
|
||||
}
|
||||
|
||||
var failed = false
|
||||
|
||||
func main() {
|
||||
|
||||
test64BitConstMult(1, 2)
|
||||
test64BitConstAdd(1, 2)
|
||||
testRegallocCVSpill(1, 2, 3, 4)
|
||||
|
||||
if failed {
|
||||
panic("failed")
|
||||
|
@ -238,7 +238,7 @@ func regalloc(f *Func) {
|
||||
if regs[r].v != nil {
|
||||
x := regs[r].v
|
||||
c := regs[r].c
|
||||
if regs[r].dirty && lastUse[x.ID] > idx {
|
||||
if regs[r].dirty && lastUse[x.ID] >= idx {
|
||||
// Write x back to home. Its value is currently held in c.
|
||||
x.Op = OpStoreReg
|
||||
x.Aux = nil
|
||||
@ -317,7 +317,7 @@ func regalloc(f *Func) {
|
||||
if regs[r].v != nil {
|
||||
x := regs[r].v
|
||||
c := regs[r].c
|
||||
if regs[r].dirty && lastUse[x.ID] > idx {
|
||||
if regs[r].dirty && lastUse[x.ID] >= idx {
|
||||
// Write x back to home. Its value is currently held in c.
|
||||
x.Op = OpStoreReg
|
||||
x.Aux = nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user