[go] cmd/compile: elide sign-extend after zero-extend for wasm

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
11:51 AM (8 hours ago) 11:51 AM
to George Adams, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Carlos Amedee, Keith Randall, Keith Randall, Go LUCI, Martin Möhrmann, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
cmd/compile: elide sign-extend after zero-extend for wasm

Add rules to eliminate sign-extension of values that have already
been zero-extended from fewer bits via an I64And mask:

(I64Extend32S x:(I64And _ (I64Const [c]))) && c >= 0 && int64(int32(c)) == c => x
(I64Extend16S x:(I64And _ (I64Const [c]))) && c >= 0 && int64(int16(c)) == c => x
(I64Extend8S x:(I64And _ (I64Const [c]))) && c >= 0 && int64(int8(c)) == c => x

When a value has been masked to fit within the non-negative range of
the sign-extension width, the upper bits are already zero and sign-
extending is a no-op. For example, (I64Extend32S (I64And x 0xff))
can be elided because 0xff fits in a signed int32, so bit 31 is
guaranteed to be zero and sign-extending from 32 bits is identity.
Cq-Include-Trybots: luci.golang.try:gotip-wasip1-wasm_wasmtime,gotip-wasip1-wasm_wazero
Change-Id: Ia54d67358756e47ca7635a6a8ca4beadb003820a
Reviewed-by: Keith Randall <k...@google.com>
Reviewed-by: Carlos Amedee <car...@golang.org>
Reviewed-by: Keith Randall <k...@golang.org>
Auto-Submit: Keith Randall <k...@golang.org>
Files:
  • M src/cmd/compile/internal/ssa/_gen/Wasm.rules
  • M src/cmd/compile/internal/ssa/rewriteWasm.go
Change size: M
Delta: 2 files changed, 67 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Keith Randall, +1 by Carlos Amedee, +1 by Keith Randall
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia54d67358756e47ca7635a6a8ca4beadb003820a
Gerrit-Change-Number: 756320
Gerrit-PatchSet: 3
Gerrit-Owner: George Adams <georgea...@gmail.com>
Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
Gerrit-Reviewer: George Adams <georgea...@gmail.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Martin Möhrmann <moeh...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages