From: Cuong Manh Le Date: Fri, 13 Sep 2019 02:58:35 +0000 (+0700) Subject: cmd/compile: remove n.SetLikely(false) usage X-Git-Tag: go1.14beta1~981 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e0dde990de11c73ae11b2f1a42de37143c6bfb7c;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index 4c89ae639b..ceec1b4dc1 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -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