From: Cherry Zhang Date: Thu, 5 May 2016 23:51:54 +0000 (-0700) Subject: cmd/compile/internal/mips64: fix large uint -> float conversion X-Git-Tag: go1.7beta1~300 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bf151cc2aa4094b4633a7e5f07a34227d58231fe;p=gostls13.git cmd/compile/internal/mips64: fix large uint -> float conversion 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 Reviewed-by: Minux Ma Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/gc/ssa_test.go b/src/cmd/compile/internal/gc/ssa_test.go index 8a233eafe0..c89917df88 100644 --- a/src/cmd/compile/internal/gc/ssa_test.go +++ b/src/cmd/compile/internal/gc/ssa_test.go @@ -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") } diff --git a/src/cmd/compile/internal/mips64/gsubr.go b/src/cmd/compile/internal/mips64/gsubr.go index 864fd76d12..eb56d8b82e 100644 --- a/src/cmd/compile/internal/mips64/gsubr.go +++ b/src/cmd/compile/internal/mips64/gsubr.go @@ -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) }