diff options
author | Keith Randall <khr@golang.org> | 2024-04-22 10:04:03 -0700 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2024-04-22 18:24:47 +0000 |
commit | 9f9dd2bfd8a09083b21767d13df38ff67d7236d8 (patch) | |
tree | 280fc98560210b586c1b36c9ac80767733bb5dde /src/cmd/compile/internal/ssa/_gen/generic.rules | |
parent | 79065f0a5eb48534142ed01d569e742b60a13f34 (diff) | |
download | go-9f9dd2bfd8a09083b21767d13df38ff67d7236d8.tar.gz go-9f9dd2bfd8a09083b21767d13df38ff67d7236d8.zip |
cmd/compile: fix cmpstring rewrite rule
We need to ensure that the Select0 lives in the same block as
its argument. Divide up the rule into 2 so that we can put the
parts in the right places.
(This would be simpler if we could use @block syntax mid-rule, but
that feature currently only works at the top level.)
This fixes the ssacheck builder after CL 578835
Change-Id: Id26a01d9fac0684e0b732d35d0f7999f6de07825
Reviewed-on: https://go-review.googlesource.com/c/go/+/580815
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/_gen/generic.rules')
-rw-r--r-- | src/cmd/compile/internal/ssa/_gen/generic.rules | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/ssa/_gen/generic.rules b/src/cmd/compile/internal/ssa/_gen/generic.rules index 398601e81b..70bac217fa 100644 --- a/src/cmd/compile/internal/ssa/_gen/generic.rules +++ b/src/cmd/compile/internal/ssa/_gen/generic.rules @@ -2799,7 +2799,11 @@ // same memory state can reuse the results of the first call. // See issue 61725. // Note that this could pretty easily generalize to any pure function. -(StaticLECall {f} x y m:(SelectN [1] c:(StaticLECall {g} x y mem))) +(SelectN [0] (StaticLECall {f} x y (SelectN [1] c:(StaticLECall {g} x y mem)))) && isSameCall(f, "runtime.cmpstring") && isSameCall(g, "runtime.cmpstring") -=> (MakeResult (SelectN [0] <typ.Int> c) m) +=> @c.Block (SelectN [0] <typ.Int> c) + +// If we don't use the result of cmpstring, might as well not call it. +// Note that this could pretty easily generalize to any pure function. +(SelectN [1] c:(StaticLECall {f} _ _ mem)) && c.Uses == 1 && isSameCall(f, "runtime.cmpstring") && clobber(c) => mem |