Commit 4f1ca8b6 authored by Cherry Zhang's avatar Cherry Zhang

cmd/internal/obj/mips: materialize float constant 0 from zero register

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: default avatarDavid Chase <drchase@google.com>
parent 0acefdbe
...@@ -58,6 +58,12 @@ func progedit(ctxt *obj.Link, p *obj.Prog) { ...@@ -58,6 +58,12 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
if p.From.Type == obj.TYPE_FCONST { if p.From.Type == obj.TYPE_FCONST {
f32 := float32(p.From.Val.(float64)) f32 := float32(p.From.Val.(float64))
i32 := math.Float32bits(f32) 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) literal := fmt.Sprintf("$f32.%08x", i32)
s := obj.Linklookup(ctxt, literal, 0) s := obj.Linklookup(ctxt, literal, 0)
s.Size = 4 s.Size = 4
...@@ -70,6 +76,12 @@ func progedit(ctxt *obj.Link, p *obj.Prog) { ...@@ -70,6 +76,12 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
case AMOVD: case AMOVD:
if p.From.Type == obj.TYPE_FCONST { if p.From.Type == obj.TYPE_FCONST {
i64 := math.Float64bits(p.From.Val.(float64)) 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) literal := fmt.Sprintf("$f64.%016x", i64)
s := obj.Linklookup(ctxt, literal, 0) s := obj.Linklookup(ctxt, literal, 0)
s.Size = 8 s.Size = 8
......
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