]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: fix SUBQ generation error
authorTodd Neal <todd@tneal.org>
Thu, 30 Jul 2015 17:57:43 +0000 (13:57 -0400)
committerTodd Neal <todd@tneal.org>
Thu, 30 Jul 2015 19:39:20 +0000 (19:39 +0000)
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>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/testdata/arith_ssa.go

index 32844093d2d8942af6a358872a543a734d4a835f..430adc31fdbd43af7eaa52c80d0e4622b3903596 100644 (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
                }
index 2731337dbf39e29f2f1b4c72f0d4dcfed8026c77..3fd2fad457596ef9bdd6999f50e51b5efd54bded 100644 (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")
        }