// (3)
a := nod(OIF, nil, nil)
a.Left = nod(OGT, gatevar, nodintconst(1))
- a.Likely = 1
+ a.SetLikely(true)
r = append(r, a)
// (3a)
a.Nbody.Set1(nod(ORETURN, nil, nil))
b.Left = nod(OEQ, gatevar, nodintconst(1))
// this actually isn't likely, but code layout is better
// like this: no JMP needed after the call.
- b.Likely = 1
+ b.SetLikely(true)
r = append(r, b)
// (4a)
b.Nbody.Set1(nod(OCALL, syslook("throwinit"), nil))
bThen := s.f.NewBlock(ssa.BlockPlain)
bEnd := s.f.NewBlock(ssa.BlockPlain)
var bElse *ssa.Block
+ var likely int8
+ if n.Likely() {
+ likely = 1
+ }
if n.Rlist.Len() != 0 {
bElse = s.f.NewBlock(ssa.BlockPlain)
- s.condBranch(n.Left, bThen, bElse, n.Likely)
+ s.condBranch(n.Left, bThen, bElse, likely)
} else {
- s.condBranch(n.Left, bThen, bEnd, n.Likely)
+ s.condBranch(n.Left, bThen, bEnd, likely)
}
s.startBlock(bThen)
Walkdef uint8 // tracks state during typecheckdef; 2 == loop detected
Typecheck uint8 // tracks state during typechecking; 2 == loop detected
Initorder uint8
- Likely int8 // likeliness of if statement
hasVal int8 // +1 for Val, -1 for Opt, 0 for not yet set
}
nodeAddable // addressable
nodeUsed // for variable/label declared and not used error
nodeHasCall // expression contains a function call
+ nodeLikely // if statement condition likely
)
func (n *Node) HasBreak() bool { return n.flags&nodeHasBreak != 0 }
func (n *Node) Addable() bool { return n.flags&nodeAddable != 0 }
func (n *Node) Used() bool { return n.flags&nodeUsed != 0 }
func (n *Node) HasCall() bool { return n.flags&nodeHasCall != 0 }
+func (n *Node) Likely() bool { return n.flags&nodeLikely != 0 }
func (n *Node) SetHasBreak(b bool) { n.flags.set(nodeHasBreak, b) }
func (n *Node) SetIsClosureVar(b bool) { n.flags.set(nodeIsClosureVar, b) }
func (n *Node) SetAddable(b bool) { n.flags.set(nodeAddable, b) }
func (n *Node) SetUsed(b bool) { n.flags.set(nodeUsed, b) }
func (n *Node) SetHasCall(b bool) { n.flags.set(nodeHasCall, b) }
+func (n *Node) SetLikely(b bool) { n.flags.set(nodeLikely, b) }
// Val returns the Val for the node.
func (n *Node) Val() Val {