diff options
| author | Keith Randall <khr@golang.org> | 2023-06-15 09:14:12 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2023-07-26 17:17:28 +0000 |
| commit | d0964e172b83db45d167b21e93b79fe86b158760 (patch) | |
| tree | 7f97e068236098c97672d22c2aa37acb9da66a2b /test/codegen/strings.go | |
| parent | f0894a00f4b756d4b9b4078af2e686b359493583 (diff) | |
| download | go-d0964e172b83db45d167b21e93b79fe86b158760.tar.xz | |
cmd/compile: optimize s==s for strings
s==s is always true for strings. This comes up in NaN testing in
generic code, where we want x==x to compile completely away except for
float types.
Fixes #60777
Change-Id: I3ce054b5121354de2f9751b010fb409f148cb637
Reviewed-on: https://go-review.googlesource.com/c/go/+/503795
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen/strings.go')
| -rw-r--r-- | test/codegen/strings.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/codegen/strings.go b/test/codegen/strings.go index 94512f5cd3..f98c062d1b 100644 --- a/test/codegen/strings.go +++ b/test/codegen/strings.go @@ -67,4 +67,14 @@ func ConstantLoad() { bsink = []byte("0123456789ab") } +// self-equality is always true. See issue 60777. +func EqualSelf(s string) bool { + // amd64:`MOVL\t\$1, AX`,-`.*memequal.*` + return s == s +} +func NotEqualSelf(s string) bool { + // amd64:`XORL\tAX, AX`,-`.*memequal.*` + return s != s +} + var bsink []byte |
