Commit e0dde990 authored by Cuong Manh Le's avatar Cuong Manh Le Committed by Matthew Dempsky

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: default avatarMatthew Dempsky <mdempsky@google.com>
parent 21bf37b5
...@@ -2711,7 +2711,8 @@ func isAppendOfMake(n *Node) bool { ...@@ -2711,7 +2711,8 @@ func isAppendOfMake(n *Node) bool {
// extendslice rewrites append(l1, make([]T, l2)...) to // extendslice rewrites append(l1, make([]T, l2)...) to
// init { // init {
// if l2 < 0 { // if l2 >= 0 { // Empty if block here for more meaningful node.SetLikely(true)
// } else {
// panicmakeslicelen() // panicmakeslicelen()
// } // }
// s := l1 // s := l1
...@@ -2750,12 +2751,12 @@ func extendslice(n *Node, init *Nodes) *Node { ...@@ -2750,12 +2751,12 @@ func extendslice(n *Node, init *Nodes) *Node {
var nodes []*Node var nodes []*Node
// if l2 < 0 // if l2 >= 0 (likely happens), do nothing
nifneg := nod(OIF, nod(OLT, l2, nodintconst(0)), nil) nifneg := nod(OIF, nod(OGE, l2, nodintconst(0)), nil)
nifneg.SetLikely(false) nifneg.SetLikely(true)
// panicmakeslicelen() // else panicmakeslicelen()
nifneg.Nbody.Set1(mkcall("panicmakeslicelen", nil, init)) nifneg.Rlist.Set1(mkcall("panicmakeslicelen", nil, init))
nodes = append(nodes, nifneg) nodes = append(nodes, nifneg)
// s := l1 // s := l1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment