Skip to content

Commit 9f9dd2b

Browse files
randall77gopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 79065f0 commit 9f9dd2b

File tree

2 files changed

+56
-32
lines changed

2 files changed

+56
-32
lines changed

src/cmd/compile/internal/ssa/_gen/generic.rules

+6-2
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,11 @@
27992799
// same memory state can reuse the results of the first call.
28002800
// See issue 61725.
28012801
// Note that this could pretty easily generalize to any pure function.
2802-
(StaticLECall {f} x y m:(SelectN [1] c:(StaticLECall {g} x y mem)))
2802+
(SelectN [0] (StaticLECall {f} x y (SelectN [1] c:(StaticLECall {g} x y mem))))
28032803
&& isSameCall(f, "runtime.cmpstring")
28042804
&& isSameCall(g, "runtime.cmpstring")
2805-
=> (MakeResult (SelectN [0] <typ.Int> c) m)
2805+
=> @c.Block (SelectN [0] <typ.Int> c)
2806+
2807+
// If we don't use the result of cmpstring, might as well not call it.
2808+
// Note that this could pretty easily generalize to any pure function.
2809+
(SelectN [1] c:(StaticLECall {f} _ _ mem)) && c.Uses == 1 && isSameCall(f, "runtime.cmpstring") && clobber(c) => mem

src/cmd/compile/internal/ssa/rewritegeneric.go

+50-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)