1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[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/12869
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Todd Neal 2015-07-30 13:57:43 -04:00
parent 359747da15
commit 9271ecc8c6
2 changed files with 15 additions and 3 deletions

View File

@ -1765,8 +1765,6 @@ func genValue(v *ssa.Value) {
p.From.Reg = y
if neg {
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.Reg = r
}

View File

@ -75,6 +75,20 @@ func testBitwiseOr_ssa(a, b uint32) uint32 {
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
func main() {
@ -82,7 +96,7 @@ func main() {
test64BitConstMult(1, 2)
test64BitConstAdd(1, 2)
testRegallocCVSpill(1, 2, 3, 4)
testSubqToNegq(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2)
if failed {
panic("failed")
}