[PATCH] D95125: [WebAssembly] Enable loop unrolling

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 21 03:57:36 PST 2021


samparker created this revision.
samparker added reviewers: sunfish, aheejin, tlively.
Herald added subscribers: ecnelises, zzheng, hiraditya, jgravelle-google, sbc100, dschuff.
samparker requested review of this revision.
Herald added a project: LLVM.

I've started looking into the performance of wasm vs native code using a small selection of the LLVM test suite, focusing on kernels and the basic stuff that could be expected in algorithms. The performance of tight kernels was particularly bad in V8 due to the inserted stack guard checks to enable any loop iteration to be interrupted. Loop unrolling seemed like the sensible thing to do to reduce this overhead, but this benefit would need to overcome the added binary size and associated compilation time. The results for wasmtime and node, using wasi-sdk, are shown below:

AdobeC++
F15127062: adobe-node.png <https://reviews.llvm.org/F15127062>

F15127061: adobe-wasmtime.png <https://reviews.llvm.org/F15127061>

F15127065: adobe-size.png <https://reviews.llvm.org/F15127065>

Polybench
F15127069: polybench-node.png <https://reviews.llvm.org/F15127069>

F15127068: polybench-wasmtime.png <https://reviews.llvm.org/F15127068>

F15127079: polybench-size.png <https://reviews.llvm.org/F15127079>

TSVC
F15127082: tsvc-wasmtime.png <https://reviews.llvm.org/F15127082>

F15127081: tsvc-node.png <https://reviews.llvm.org/F15127081>

F15127083: tsvc-size.png <https://reviews.llvm.org/F15127083>

This patch enables loop unrolling by default for wasm, using a threshold of 30 as the results suggest the gains generally tail off after this, as the binary size also increases. Polybench on the Raspberry Pi via wasmtime doesn't share the performance uplift like the other benchmarks on the other platforms, but I'm not sure why.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95125

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h
  llvm/test/Transforms/LoopUnroll/WebAssembly/basic-unrolling.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95125.318144.patch
Type: text/x-patch
Size: 15753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210121/cd9db5e7/attachment.bin>


More information about the llvm-commits mailing list