]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile/internal/ssa: treat -0.0 literal as 0.0
authorTodd Neal <todd@tneal.org>
Tue, 8 Sep 2015 11:50:25 +0000 (07:50 -0400)
committerTodd Neal <todd@tneal.org>
Thu, 10 Sep 2015 00:25:18 +0000 (00:25 +0000)
This matches existing behavior, see issue #2196

Change-Id: Ifa9359b7c821115389f337a57de355c5ec23be8f
Reviewed-on: https://go-review.googlesource.com/14261
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
test/run.go

index 9d87f38ea190f1f4c258f46945bdffb74f3c00a5..386420f26b56654eb56bd098445a842a5dd9ea82 100644 (file)
@@ -1254,9 +1254,11 @@ func (s *state) expr(n *Node) *ssa.Value {
                        f := n.Val().U.(*Mpflt)
                        switch n.Type.Size() {
                        case 4:
-                               return s.constFloat32(n.Type, mpgetflt32(f))
+                               // -0.0 literals need to be treated as if they were 0.0, adding 0.0 here
+                               // accomplishes this while not affecting other values.
+                               return s.constFloat32(n.Type, mpgetflt32(f)+0.0)
                        case 8:
-                               return s.constFloat64(n.Type, mpgetflt(f))
+                               return s.constFloat64(n.Type, mpgetflt(f)+0.0)
                        default:
                                s.Fatalf("bad float size %d", n.Type.Size())
                                return nil
@@ -1269,16 +1271,18 @@ func (s *state) expr(n *Node) *ssa.Value {
                        case 8:
                                {
                                        pt := Types[TFLOAT32]
+                                       // -0.0 literals need to be treated as if they were 0.0, adding 0.0 here
+                                       // accomplishes this while not affecting other values.
                                        return s.newValue2(ssa.OpComplexMake, n.Type,
-                                               s.constFloat32(pt, mpgetflt32(r)),
-                                               s.constFloat32(pt, mpgetflt32(i)))
+                                               s.constFloat32(pt, mpgetflt32(r)+0.0),
+                                               s.constFloat32(pt, mpgetflt32(i)+0.0))
                                }
                        case 16:
                                {
                                        pt := Types[TFLOAT64]
                                        return s.newValue2(ssa.OpComplexMake, n.Type,
-                                               s.constFloat64(pt, mpgetflt(r)),
-                                               s.constFloat64(pt, mpgetflt(i)))
+                                               s.constFloat64(pt, mpgetflt(r)+0.0),
+                                               s.constFloat64(pt, mpgetflt(i)+0.0))
                                }
                        default:
                                s.Fatalf("bad float size %d", n.Type.Size())
index 1f9b905ea33fe33ad85ea9fcdca80bb6a2ea68bc..de2044704c021200c7f3da134247eeb20d3dacc3 100644 (file)
@@ -636,13 +636,7 @@ func (t *test) run() {
                }
 
        case "run":
-               useTmp = false
-               switch t.gofile {
-               case "bug434.go":
-                       // TODO fix this failure
-               default:
-                       ssaMain = true
-               }
+               ssaMain = true
                out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
                if err != nil {
                        t.err = err