Commit 9271ecc8 authored by Todd Neal's avatar Todd Neal

[dev.ssa] cmd/compile: fix SUBQ generation error

Fix code generation error that resulted in a multi-argument NEGQ

doasm: notfound ft=13 tt=13 00134 NEGQ	AX, AX 13 13

Change-Id: I8b712d21a5523eccbae1f33ccea417844c27073e
Reviewed-on: https://go-review.googlesource.com/12869Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 359747da
...@@ -1765,8 +1765,6 @@ func genValue(v *ssa.Value) { ...@@ -1765,8 +1765,6 @@ func genValue(v *ssa.Value) {
p.From.Reg = y p.From.Reg = y
if neg { if neg {
p := Prog(x86.ANEGQ) // TODO: use correct size? This is mostly a hack until regalloc does 2-address correctly p := Prog(x86.ANEGQ) // TODO: use correct size? This is mostly a hack until regalloc does 2-address correctly
p.From.Type = obj.TYPE_REG
p.From.Reg = r
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
p.To.Reg = r p.To.Reg = r
} }
......
...@@ -75,6 +75,20 @@ func testBitwiseOr_ssa(a, b uint32) uint32 { ...@@ -75,6 +75,20 @@ func testBitwiseOr_ssa(a, b uint32) uint32 {
return a | b return a | b
} }
// testSubqToNegq ensures that the SUBQ -> NEGQ translation works correctly.
func testSubqToNegq(a, b, c, d, e, f, g, h, i, j, k int64) {
want := a + 8207351403619448057 - b - 1779494519303207690 + c*8810076340510052032*d - 4465874067674546219 - e*4361839741470334295 - f + 8688847565426072650*g*8065564729145417479
if got := testSubqToNegq_ssa(a, b, c, d, e, f, g, h, i, j, k); want != got {
println("testSubqToNegq failed, wanted", want, "got", got)
failed = true
}
}
func testSubqToNegq_ssa(a, b, c, d, e, f, g, h, i, j, k int64) int64 {
switch { // prevent inlining
}
return a + 8207351403619448057 - b - 1779494519303207690 + c*8810076340510052032*d - 4465874067674546219 - e*4361839741470334295 - f + 8688847565426072650*g*8065564729145417479
}
var failed = false var failed = false
func main() { func main() {
...@@ -82,7 +96,7 @@ func main() { ...@@ -82,7 +96,7 @@ func main() {
test64BitConstMult(1, 2) test64BitConstMult(1, 2)
test64BitConstAdd(1, 2) test64BitConstAdd(1, 2)
testRegallocCVSpill(1, 2, 3, 4) testRegallocCVSpill(1, 2, 3, 4)
testSubqToNegq(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2)
if failed { if failed {
panic("failed") panic("failed")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment