Change information
Commit message:
cmd/compile: eliminate redundant sign-extensions for wasm
Add rules to eliminate redundant I64Extend sign-extension operations
in the wasm backend:
Idempotent (applying the same extend twice is redundant):
(I64Extend32S (I64Extend32S x)) => (I64Extend32S x)
(I64Extend16S (I64Extend16S x)) => (I64Extend16S x)
(I64Extend8S (I64Extend8S x)) => (I64Extend8S x)
Narrower-subsumes-wider (a narrower sign-extend already determines
all the bits that a wider one would set):
(I64Extend32S (I64Extend16S x)) => (I64Extend16S x)
(I64Extend32S (I64Extend8S x)) => (I64Extend8S x)
(I64Extend16S (I64Extend8S x)) => (I64Extend8S x)
These patterns arise from nested sub-word type conversions. For
example, converting int8 -> int16 -> int32 -> int64 lowers to
I64Extend8S -> I64Extend16S -> I64Extend32S, but the I64Extend8S
alone is sufficient since it already sign-extends from 8 to 64 bits.
Cq-Include-Trybots: luci.golang.try:gotip-wasip1-wasm_wasmtime,gotip-wasip1-wasm_wazero
Change-Id: I1637687df31893b1ffa36915a3bd2e10d455f4ef
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, 92 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +1 by Carlos Amedee, +1 by Keith Randall, +2 by Keith Randall
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI