mirror of
https://github.com/golang/go
synced 2024-11-18 04:04:49 -07:00
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: David Chase <drchase@google.com>
This commit is contained in:
parent
0acefdbea0
commit
4f1ca8b6f9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user