compiler: optimize 0,1,2-case select statement

For a select statement with zero-, one-, or two-case with a
default case, we can generate simpler code instead of calling the
generic selectgo. A zero-case select is just blocking the
execution. A one-case select is mostly just executing the case. A
two-case select with a default case is a non-blocking send or
receive. We add these special cases for lowering a select
statement.

Change-Id: I519d246a4a5ba6871bb303160bba1ec1e3074bd0
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/184998
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 files changed