]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/mips: materialize float constant 0 from zero register
authorCherry Zhang <cherryyz@google.com>
Thu, 27 Oct 2016 21:52:53 +0000 (17:52 -0400)
committerCherry Zhang <cherryyz@google.com>
Fri, 28 Oct 2016 14:20:09 +0000 (14:20 +0000)
Materialize float constant 0 from integer zero register, instead
of loading from constant pool.

Change-Id: Ie4728895b9d617bec2a29d15729c0efaa10eedbb
Reviewed-on: https://go-review.googlesource.com/32109
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/internal/obj/mips/obj0.go

index 402b65eb27774893a94bd68fe0649238d62e34db..651da239554c3b422c661d7a024cb0a8ab060d3b 100644 (file)
@@ -58,6 +58,12 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
                if p.From.Type == obj.TYPE_FCONST {
                        f32 := float32(p.From.Val.(float64))
                        i32 := math.Float32bits(f32)
+                       if i32 == 0 {
+                               p.As = AMOVV
+                               p.From.Type = obj.TYPE_REG
+                               p.From.Reg = REGZERO
+                               break
+                       }
                        literal := fmt.Sprintf("$f32.%08x", i32)
                        s := obj.Linklookup(ctxt, literal, 0)
                        s.Size = 4
@@ -70,6 +76,12 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
        case AMOVD:
                if p.From.Type == obj.TYPE_FCONST {
                        i64 := math.Float64bits(p.From.Val.(float64))
+                       if i64 == 0 {
+                               p.As = AMOVV
+                               p.From.Type = obj.TYPE_REG
+                               p.From.Reg = REGZERO
+                               break
+                       }
                        literal := fmt.Sprintf("$f64.%016x", i64)
                        s := obj.Linklookup(ctxt, literal, 0)
                        s.Size = 8