diff options
| author | Keith Randall <khr@golang.org> | 2024-12-09 12:55:33 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-02-10 13:28:41 -0800 |
| commit | 072eea9b3b8e3c871707b5661948edd4090fc56a (patch) | |
| tree | a4087fd48ff5cd8c5f889aca6387a60d083e9155 /test/codegen | |
| parent | c8664ced4ef61456a98acb9f910b1646ae81e3b5 (diff) | |
| download | go-072eea9b3b8e3c871707b5661948edd4090fc56a.tar.xz | |
cmd/compile: avoid ifaceeq call if we know the interface is direct
We can just use == if the interface is direct.
Fixes #70738
Change-Id: Ia9a644791a370fec969c04c42d28a9b58f16911f
Reviewed-on: https://go-review.googlesource.com/c/go/+/635435
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/ifaces.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/codegen/ifaces.go b/test/codegen/ifaces.go index 2be3fa5146..cc67a04740 100644 --- a/test/codegen/ifaces.go +++ b/test/codegen/ifaces.go @@ -25,3 +25,39 @@ func ConvToM(x any) I { // arm64:`CALL\truntime.typeAssert`,`LDAR`,`MOVWU`,`MOVD\t\(R.*\)\(R.*\)` return x.(I) } + +func e1(x any, y *int) bool { + // amd64:-`.*faceeq`,`SETEQ` + // arm64:-`.*faceeq`,`CSET\tEQ` + return x == y +} + +func e2(x any, y *int) bool { + // amd64:-`.*faceeq`,`SETEQ` + // arm64:-`.*faceeq`,`CSET\tEQ` + return y == x +} + +type E *int + +func e3(x any, y E) bool { + // amd64:-`.*faceeq`,`SETEQ` + // arm64:-`.*faceeq`,`CSET\tEQ` + return x == y +} + +type T int + +func (t *T) M() {} + +func i1(x I, y *T) bool { + // amd64:-`.*faceeq`,`SETEQ` + // arm64:-`.*faceeq`,`CSET\tEQ` + return x == y +} + +func i2(x I, y *T) bool { + // amd64:-`.*faceeq`,`SETEQ` + // arm64:-`.*faceeq`,`CSET\tEQ` + return y == x +} |
