mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.regabi] cmd/compile: handle OCONVNOP better in ssa
This CL improves handling of OCONVNOP nodes during ssa generation, so it is not toolstash safe. An OCONVNOP wrapper is necessary for the "for" condition of certain compiled range loops, and the boolean evaluator was not looking through them properly, generating unnecessary temporaries. That change saved 8k of the (13 MB) go binary. The other changes just streamline the handling of OCONVNOP to be more like what OSTMTEXPR will be like. They have no effect on output size but do tweak the ssa graph a little, which causes different register decisions and therefore different output. Change-Id: I9e1dcd413b60944e21554c3e3f2bdc9adcee7634 Reviewed-on: https://go-review.googlesource.com/c/go/+/274598 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
00e5727790
commit
59b8916d48
2 changed files with 13 additions and 0 deletions
|
|
@ -2103,6 +2103,9 @@ func (s *state) expr(n ir.Node) *ssa.Value {
|
|||
// Assume everything will work out, so set up our return value.
|
||||
// Anything interesting that happens from here is a fatal.
|
||||
x := s.expr(n.Left())
|
||||
if to == from {
|
||||
return x
|
||||
}
|
||||
|
||||
// Special case for not confusing GC and liveness.
|
||||
// We don't want pointers accidentally classified
|
||||
|
|
@ -2966,6 +2969,10 @@ func (s *state) condBranch(cond ir.Node, yes, no *ssa.Block, likely int8) {
|
|||
s.stmtList(cond.Init())
|
||||
s.condBranch(cond.Left(), no, yes, -likely)
|
||||
return
|
||||
case ir.OCONVNOP:
|
||||
s.stmtList(cond.Init())
|
||||
s.condBranch(cond.Left(), yes, no, likely)
|
||||
return
|
||||
}
|
||||
c := s.expr(cond)
|
||||
b := s.endBlock()
|
||||
|
|
@ -4903,6 +4910,9 @@ func (s *state) addr(n ir.Node) *ssa.Value {
|
|||
return s.newValue1I(ssa.OpOffPtr, t, n.Offset(),
|
||||
s.entryNewValue0(ssa.OpGetClosurePtr, s.f.Config.Types.BytePtr))
|
||||
case ir.OCONVNOP:
|
||||
if n.Type() == n.Left().Type() {
|
||||
return s.addr(n.Left())
|
||||
}
|
||||
addr := s.addr(n.Left())
|
||||
return s.newValue1(ssa.OpCopy, t, addr) // ensure that addr has the right type
|
||||
case ir.OCALLFUNC, ir.OCALLINTER, ir.OCALLMETH:
|
||||
|
|
|
|||
|
|
@ -966,6 +966,9 @@ opswitch:
|
|||
|
||||
case ir.OCONV, ir.OCONVNOP:
|
||||
n.SetLeft(walkexpr(n.Left(), init))
|
||||
if n.Op() == ir.OCONVNOP && n.Type() == n.Left().Type() {
|
||||
return n.Left()
|
||||
}
|
||||
if n.Op() == ir.OCONVNOP && checkPtr(Curfn, 1) {
|
||||
if n.Type().IsPtr() && n.Left().Type().IsUnsafePtr() { // unsafe.Pointer to *T
|
||||
n = walkCheckPtrAlignment(n, init, nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue