]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/mips64: fix large uint -> float conversion
authorCherry Zhang <cherryyz@google.com>
Thu, 5 May 2016 23:51:54 +0000 (16:51 -0700)
committerCherry Zhang <cherryyz@google.com>
Fri, 6 May 2016 16:02:30 +0000 (16:02 +0000)
Re-enable TestFP in cmd/compile/internal/gc on mips64.

Fixes #15552.

Change-Id: I5c3a5564b94d28c723358f0862468fb6da371991
Reviewed-on: https://go-review.googlesource.com/22835
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/ssa_test.go
src/cmd/compile/internal/mips64/gsubr.go

index 8a233eafe0d6d7d5d330c893c2e0ff270d2c1804..c89917df88c2685ab577bdc38948db5b2d368983 100644 (file)
@@ -57,12 +57,7 @@ func TestArithmetic(t *testing.T) {
 }
 
 // TestFP tests that both backends have the same result for floating point expressions.
-func TestFP(t *testing.T) {
-       if runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" {
-               t.Skip("legacy mips64 compiler doesn't handle uint->float conversion correctly (issue 15552)")
-       }
-       runTest(t, "fp_ssa.go")
-}
+func TestFP(t *testing.T) { runTest(t, "fp_ssa.go") }
 
 // TestArithmeticBoundary tests boundary results for arithmetic operations.
 func TestArithmeticBoundary(t *testing.T) { runTest(t, "arithBoundary_ssa.go") }
index 864fd76d121f9e73143121839930a97a7c75ee99..eb56d8b82e6e9319265206ba3c5b1a7fd20b0db7 100644 (file)
@@ -466,7 +466,7 @@ func gmove(f *gc.Node, t *gc.Node) {
        //return;
        // algorithm is:
        //      if small enough, use native int64 -> float64 conversion.
-       //      otherwise, halve (rounding to odd?), convert, and double.
+       //      otherwise, halve (x -> (x>>1)|(x&1)), convert, and double.
        /*
         * integer to float
         */
@@ -496,9 +496,16 @@ func gmove(f *gc.Node, t *gc.Node) {
                        gmove(&bigi, &rtmp)
                        gins(mips.AAND, &r1, &rtmp)
                        p1 := ginsbranch(mips.ABEQ, nil, &rtmp, nil, 0)
-                       p2 := gins(mips.ASRLV, nil, &r1)
+                       var r3 gc.Node
+                       gc.Regalloc(&r3, gc.Types[gc.TUINT64], nil)
+                       p2 := gins3(mips.AAND, nil, &r1, &r3)
                        p2.From.Type = obj.TYPE_CONST
                        p2.From.Offset = 1
+                       p3 := gins(mips.ASRLV, nil, &r1)
+                       p3.From.Type = obj.TYPE_CONST
+                       p3.From.Offset = 1
+                       gins(mips.AOR, &r3, &r1)
+                       gc.Regfree(&r3)
                        gc.Patch(p1, gc.Pc)
                }