mirror of https://github.com/golang/go.git
cmd/internal/obj/arm64: materialize float constant 0 from zero register
Materialize float constant 0 from integer zero register, instead of loading from constant pool. Also fix assembling FMOV from zero register to FP register. Change-Id: Ie413dd342cedebdb95ba8cfc220e23ed2a39e885 Reviewed-on: https://go-review.googlesource.com/32250 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
9d1efba28d
commit
a866df2671
|
|
@ -2380,13 +2380,15 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
|
|||
o2 |= uint32(p.To.Reg & 31)
|
||||
|
||||
case 29: /* op Rn, Rd */
|
||||
if (p.As == AFMOVD || p.As == AFMOVS) && (aclass(ctxt, &p.From) == C_REG || aclass(ctxt, &p.To) == C_REG) {
|
||||
fc := aclass(ctxt, &p.From)
|
||||
tc := aclass(ctxt, &p.To)
|
||||
if (p.As == AFMOVD || p.As == AFMOVS) && (fc == C_REG || fc == C_ZCON || tc == C_REG || tc == C_ZCON) {
|
||||
// FMOV Rx, Fy or FMOV Fy, Rx
|
||||
o1 = FPCVTI(0, 0, 0, 0, 6)
|
||||
if p.As == AFMOVD {
|
||||
o1 |= 1<<31 | 1<<22 // 64-bit
|
||||
}
|
||||
if aclass(ctxt, &p.From) == C_REG {
|
||||
if fc == C_REG || fc == C_ZCON {
|
||||
o1 |= 1 << 16 // FMOV Rx, Fy
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -262,6 +262,11 @@ 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.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
|
||||
|
|
@ -275,6 +280,11 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
|
|||
case AFMOVD:
|
||||
if p.From.Type == obj.TYPE_FCONST {
|
||||
i64 := math.Float64bits(p.From.Val.(float64))
|
||||
if i64 == 0 {
|
||||
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