mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
1 changed files with 12 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue