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

Change-Id: I519d246a4a5ba6871bb303160bba1ec1e3074bd0
Reviewed-by: Ian Lance Taylor <>
6 files changed