]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: fix complex128
authorTodd Neal <todd@tneal.org>
Thu, 3 Sep 2015 02:11:32 +0000 (21:11 -0500)
committerTodd Neal <todd@tneal.org>
Thu, 3 Sep 2015 03:04:36 +0000 (03:04 +0000)
complex128 was being treated as a complex64

Fixes math/cmplx.

Change-Id: I2996915b4cb6b94198d41cf08a30bd8531b9fec5
Reviewed-on: https://go-review.googlesource.com/14206
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/testdata/fp_ssa.go

index 61e17ee68b2c4165b42d8e5617c8342c83364bde..77c822787d82971f011ebe90d441b1f5227e70fd 100644 (file)
@@ -1139,8 +1139,8 @@ func (s *state) expr(n *Node) *ssa.Value {
                                {
                                        pt := Types[TFLOAT64]
                                        return s.newValue2(ssa.OpComplexMake, n.Type,
-                                               s.constFloat32(pt, mpgetflt(r)),
-                                               s.constFloat32(pt, mpgetflt(i)))
+                                               s.constFloat64(pt, mpgetflt(r)),
+                                               s.constFloat64(pt, mpgetflt(i)))
                                }
                        default:
                                s.Fatalf("bad float size %d", n.Type.Size())
index ee3163abb3ae3da35edf83fbb4ad4f2686bb7ada..9bd545f878b6147d5acf30ffb38423c707aa1f82 100644 (file)
@@ -1467,42 +1467,69 @@ func expectCx64(s string, x, expected complex64) int {
 }
 
 func cx128sum_ssa(a, b complex128) complex128 {
+       switch { // prevent inlining
+       }
        return a + b
 }
 
 func cx128diff_ssa(a, b complex128) complex128 {
+       switch { // prevent inlining
+       }
        return a - b
 }
 
 func cx128prod_ssa(a, b complex128) complex128 {
+       switch { // prevent inlining
+       }
        return a * b
 }
 
 func cx128quot_ssa(a, b complex128) complex128 {
+       switch { // prevent inlining
+       }
        return a / b
 }
 
 func cx128neg_ssa(a complex128) complex128 {
+       switch { // prevent inlining
+       }
        return -a
 }
 
+func cx128cnst_ssa(a complex128) complex128 {
+       switch { // prevent inlining
+       }
+       b := 2 + 3i
+       return a * b
+}
+
 func cx64sum_ssa(a, b complex64) complex64 {
+       switch { // prevent inlining
+       }
        return a + b
 }
 
 func cx64diff_ssa(a, b complex64) complex64 {
+       switch { // prevent inlining
+       }
        return a - b
 }
 
 func cx64prod_ssa(a, b complex64) complex64 {
+       switch { // prevent inlining
+       }
        return a * b
 }
 
 func cx64quot_ssa(a, b complex64) complex64 {
+       switch { // prevent inlining
+       }
        return a / b
 }
 
 func cx64neg_ssa(a complex64) complex64 {
+       switch { // prevent inlining
+       }
        return -a
 }
 
@@ -1515,12 +1542,14 @@ func complexTest128() int {
        prod := cx128prod_ssa(b, a)
        quot := cx128quot_ssa(b, a)
        neg := cx128neg_ssa(a)
+       cnst := cx128cnst_ssa(a)
 
        fails += expectCx128("sum", sum, 4+8i)
        fails += expectCx128("diff", diff, 2+4i)
        fails += expectCx128("prod", prod, -9+12i)
        fails += expectCx128("quot", quot, 3+0i)
        fails += expectCx128("neg", neg, -1-2i)
+       fails += expectCx128("cnst", cnst, -4+7i)
 
        return fails
 }