Commit bf151cc2 authored by Cherry Zhang's avatar Cherry Zhang

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/22835Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: 's avatarMinux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent fafadc52
......@@ -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") }
......
......@@ -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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment