cmd/compile: allow unaligned load/store on Wasm

Wasm supports unaligned load/store instructions. Use them.

This speeds up map hashing slightly (among others):
goos: js
goarch: wasm
pkg: runtime
                     │   old.txt   │               new.txt               │
                     │   sec/op    │   sec/op     vs base                │
Hash5                  14.06n ± 2%   13.83n ± 5%        ~ (p=0.186 n=10)
Hash16                 17.52n ± 1%   17.04n ± 1%   -2.71% (p=0.000 n=10)
Hash64                 28.68n ± 1%   26.61n ± 1%   -7.18% (p=0.000 n=10)
Hash1024               271.4n ± 0%   243.6n ± 1%  -10.21% (p=0.000 n=10)
Hash65536              16.66µ ± 0%   15.74µ ± 1%   -5.49% (p=0.000 n=10)
HashStringSpeed        29.23n ± 1%   28.70n ± 1%   -1.83% (p=0.000 n=10)
HashBytesSpeed         46.11n ± 4%   45.17n ± 5%   -2.04% (p=0.008 n=10)
HashInt32Speed         20.39n ± 1%   20.24n ± 5%        ~ (p=0.239 n=10)
HashInt64Speed         20.81n ± 7%   20.58n ± 7%        ~ (p=0.238 n=10)
HashStringArraySpeed   76.65n ± 2%   73.72n ± 1%   -3.83% (p=0.000 n=10)
FastrandHashiter       87.65n ± 1%   87.58n ± 1%        ~ (p=0.725 n=10)
geomean                67.03n        64.75n        -3.40%

Change-Id: I7fd1817c74323f628f310393b0330a0a51ffa3a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/714720
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Cherry Mui 2025-10-24 15:06:41 -04:00
parent 12ec09f434
commit 53ad68de4b

View file

@ -356,6 +356,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize, softfloat boo
c.hasGReg = true
c.useAvg = false
c.useHmul = false
c.unalignedOK = true
default:
ctxt.Diag("arch %s not implemented", arch)
}