diff options
author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2020-08-29 03:25:21 +0700 |
---|---|---|
committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2020-08-29 08:02:52 +0000 |
commit | 27a30186abc18a8fc22b8ab40e3ee9f29d81c1d4 (patch) | |
tree | 0eb89a0317307b9b7409943e3ee8c8a7b38a7627 /test/codegen | |
parent | 49bae984955bd57302895beba2ecd8b9d5cd764c (diff) | |
download | go-27a30186abc18a8fc22b8ab40e3ee9f29d81c1d4.tar.gz go-27a30186abc18a8fc22b8ab40e3ee9f29d81c1d4.zip |
cmd/compile,runtime: skip zero'ing order array for select statements
The order array was zero initialized by the compiler, but ends up being
overwritten by the runtime anyway.
So let the runtime takes full responsibility for initializing, save us
one instruction per select.
Fixes #40399
Change-Id: Iec1eca27ad7180d4fcb3cc9ef97348206b7fe6b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/251517
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r-- | test/codegen/select.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/codegen/select.go b/test/codegen/select.go new file mode 100644 index 0000000000..4426924b36 --- /dev/null +++ b/test/codegen/select.go @@ -0,0 +1,20 @@ +// asmcheck + +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package codegen + +func f() { + ch1 := make(chan int) + ch2 := make(chan int) + for { + // amd64:-`MOVQ\t[$]0, ""..autotmp_3` + select { + case <-ch1: + case <-ch2: + default: + } + } +} |