]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: avoid dynamic type when possible
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 30 Sep 2024 19:30:39 +0000 (02:30 +0700)
committerGopher Robot <gobot@golang.org>
Mon, 7 Oct 2024 19:12:01 +0000 (19:12 +0000)
commit7e2487cf65f749528c17adf95ad2a82196f48de2
treeb462c4e17332df68960840185895145233f74cc3
parent6a3f39a9b856c7fd063d9bc10c1e43f074fa8867
cmd/compile: avoid dynamic type when possible

If the expression type is a single compile-time known type, use that
type instead of the dynamic one, so the later passes of the compiler
could skip un-necessary runtime calls.

Thanks Youlin Feng for writing the original test case.

Change-Id: I3f65ab90f041474a9731338a82136c1d394c1773
Reviewed-on: https://go-review.googlesource.com/c/go/+/616975
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/ir/type.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/walk/switch.go
test/codegen/typeswitch.go [new file with mode: 0644]