]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: tweak OIF construction for binarySearch
authorMatthew Dempsky <mdempsky@google.com>
Fri, 13 Sep 2019 22:13:22 +0000 (15:13 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 18 Sep 2019 01:38:33 +0000 (01:38 +0000)
commit1b2c7948963543286516f78f0b0d52956f58d82c
tree6d34a633bc5640907aaf20216fb27befd1c97170
parent04fb929a5b7991ed0945d05ab8015c1721958d82
cmd/compile: tweak OIF construction for binarySearch

When emitting base cases, previously we would emit:

    if c1 { s1 }
    if c2 { s2 }
    if c3 { s3 }

With this CL, we instead emit:

    if c1 { s1 }
    else if c2 { s2 }
    else if c3 { s3 }

Most of the time, this doesn't make a difference, because s1/s2/s3 are
typically "goto" statements. But for type switches, we currently emit:

    if hash == 271 { if _, ok := iface.(T1); ok { goto t1case } }
    if hash == 314 { if _, ok := iface.(T2); ok { goto t2case } }

That is, the if bodies can fallthrough, even though it's impossible
for them to match any of the subsequent cases.

Change-Id: I453d424d0b5e40060a703738bbb374523f1c403c
Reviewed-on: https://go-review.googlesource.com/c/go/+/195339
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/swt.go