diff options
| author | Alexander Musman <alexander.musman@gmail.com> | 2025-07-05 23:16:36 +0300 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-11-26 09:58:51 -0800 |
| commit | dda7c8253dd5e4dc5732187f1c039325bca53c8c (patch) | |
| tree | 7ad50fc4241295887289c38e1f2299b5df320689 /src/cmd/compile/internal/ssa/_gen/generic.rules | |
| parent | 4976606a2f9203f4520c28d775e67fc32f5853ed (diff) | |
| download | go-dda7c8253dd5e4dc5732187f1c039325bca53c8c.tar.xz | |
cmd/compile,internal/bytealg: add MemEq intrinsic for runtime.memequal
Introduce a new MemEq SSA operation for runtime.memequal. The operation
is initially implemented for arm64. The change adds opt rules (following
existing rules for call to runtime.memequal), working with MemEq, and a
later op version LoweredMemEq which may be lowered differently for more
constant size cases in future (for other targets as well as for arm64).
The new MemEq SSA operation does not have memory result, allowing cse of
loads operations around it.
Code size difference (for arm64 linux):
Executable Old .text New .text Change
-------------------------------------------------------
asm 1970420 1969668 -0.04%
cgo 1741220 1740212 -0.06%
compile 8956756 8959428 +0.03%
cover 1879332 1878772 -0.03%
link 2574116 2572660 -0.06%
preprofile 867124 866820 -0.04%
vet 2890404 2888596 -0.06%
Change-Id: I6ab507929b861884d17d5818cfbd152cf7879751
Reviewed-on: https://go-review.googlesource.com/c/go/+/686655
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/_gen/generic.rules')
| -rw-r--r-- | src/cmd/compile/internal/ssa/_gen/generic.rules | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/_gen/generic.rules b/src/cmd/compile/internal/ssa/_gen/generic.rules index 90ff0b74ec..7710f6f209 100644 --- a/src/cmd/compile/internal/ssa/_gen/generic.rules +++ b/src/cmd/compile/internal/ssa/_gen/generic.rules @@ -1525,6 +1525,41 @@ && isSamePtr(p, q) => (MakeResult (ConstBool <typ.Bool> [true]) mem) +(MemEq sptr tptr (Const64 [1]) mem) + => (Eq8 (Load <typ.Int8> sptr mem) (Load <typ.Int8> tptr mem)) + +(Load <typ.Int8> sptr:(Addr {scon} (SB)) mem) + && symIsRO(scon) + => (Const8 <typ.Int8> [int8(read8(scon,0))]) + +(MemEq sptr tptr (Const64 [2]) mem) + && canLoadUnaligned(config) + => (Eq16 (Load <typ.Int16> sptr mem) (Load <typ.Int16> tptr mem)) + +(Load <typ.Int16> sptr:(Addr {scon} (SB)) mem) + && symIsRO(scon) + => (Const16 <typ.Int16> [int16(read16(scon,0,config.ctxt.Arch.ByteOrder))]) + +(MemEq sptr tptr (Const64 [4]) mem) + && canLoadUnaligned(config) + => (Eq32 (Load <typ.Int32> sptr mem) (Load <typ.Int32> tptr mem)) + +(Load <typ.Int32> sptr:(Addr {scon} (SB)) mem) + && symIsRO(scon) + => (Const32 <typ.Int32> [int32(read32(scon,0,config.ctxt.Arch.ByteOrder))]) + +(MemEq sptr tptr (Const64 [8]) mem) + && canLoadUnaligned(config) && config.PtrSize == 8 + => (Eq64 (Load <typ.Int64> sptr mem) (Load <typ.Int64> tptr mem)) + +(Load <typ.Int64> sptr:(Addr {scon} (SB)) mem) + && symIsRO(scon) + => (Const64 <typ.Int64> [int64(read64(scon,0,config.ctxt.Arch.ByteOrder))]) + +(MemEq _ _ (Const64 [0]) _) => (ConstBool <typ.Bool> [true]) + +(MemEq p q _ _) && isSamePtr(p, q) => (ConstBool <typ.Bool> [true]) + // Turn known-size calls to memclrNoHeapPointers into a Zero. // Note that we are using types.Types[types.TUINT8] instead of sptr.Type.Elem() - see issue 55122 and CL 431496 for more details. (SelectN [0] call:(StaticCall {sym} sptr (Const(64|32) [c]) mem)) |
