1
0
mirror of https://github.com/golang/go synced 2024-11-19 02:54:42 -07:00

cmd/compile: remove n.SetLikely(false) usage

n.SetLikely(false) is probably mean to indicate that the branch is
"unlikely", but it has the real effect of not marking branch as likely.

So invert the test condition, we can use more meaningful n.SetLikely(true).

Before:

	if l2 < 0 {
		panicmakeslicelen()
	}

After:

	if l2 >= 0 {
	} else {
		panicmakeslicelen
	}

Fixes #32486

Change-Id: I156fdba1f9a5d554a178c8903f1a391ed304199d
Reviewed-on: https://go-review.googlesource.com/c/go/+/195197
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2019-09-13 09:58:35 +07:00 committed by Matthew Dempsky
parent 21bf37b5a2
commit e0dde990de

View File

@ -2711,7 +2711,8 @@ func isAppendOfMake(n *Node) bool {
// extendslice rewrites append(l1, make([]T, l2)...) to
// init {
// if l2 < 0 {
// if l2 >= 0 { // Empty if block here for more meaningful node.SetLikely(true)
// } else {
// panicmakeslicelen()
// }
// s := l1
@ -2750,12 +2751,12 @@ func extendslice(n *Node, init *Nodes) *Node {
var nodes []*Node
// if l2 < 0
nifneg := nod(OIF, nod(OLT, l2, nodintconst(0)), nil)
nifneg.SetLikely(false)
// if l2 >= 0 (likely happens), do nothing
nifneg := nod(OIF, nod(OGE, l2, nodintconst(0)), nil)
nifneg.SetLikely(true)
// panicmakeslicelen()
nifneg.Nbody.Set1(mkcall("panicmakeslicelen", nil, init))
// else panicmakeslicelen()
nifneg.Rlist.Set1(mkcall("panicmakeslicelen", nil, init))
nodes = append(nodes, nifneg)
// s := l1