New LLVM 14 performance optimization

189 views
Skip to first unread message

Soeren Balko

unread,
Dec 6, 2021, 7:08:05 PM12/6/21
to emscripten-discuss
Saw this today:  LLVM Clang 14 Lands An "Amazing" Performance Optimization - Phoronix

Looks like a fairly substantial gain for some workloads. Will this also apply to the WebAssembly target? 


Thomas Lively

unread,
Dec 7, 2021, 8:52:41 AM12/7/21
to emscripte...@googlegroups.com
Yes, from the description in that article I would expect that optimization to apply to the Wasm target as well. 

Thomas

On Mon, Dec 6, 2021 at 20:04 Soeren Balko <soe...@clipchamp.com> wrote:
Saw this today:  LLVM Clang 14 Lands An "Amazing" Performance Optimization - Phoronix

Looks like a fairly substantial gain for some workloads. Will this also apply to the WebAssembly target? 


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/243b4dc8-4305-4af5-9e9d-dff8c0e84c4bn%40googlegroups.com.

Alon Zakai

unread,
Dec 7, 2021, 12:25:48 PM12/7/21
to emscripte...@googlegroups.com
Looks like that patch landed Dec 2, so it is already in the latest tip of tree build of emscripten, which people can try with

emsdk install tot



Soeren Balko

unread,
Jan 12, 2022, 1:26:55 AM1/12/22
to emscripten-discuss
So I just installed the emsdk "top of tree" that comes with LLVM 14. Turns out that gives me some ~5% performance improvement in some workloads (HEVC decoding with FFmpeg, which was already hand-optimised to use WebAssembly SIMD intrinsics). Which is great - if only I knew where that's coming from...

Specifically, what is not clear to me is the following:

(1) Is the new load hoisting optimization automatically performed as part of LLVM/s LICM pass? That's probably more a question to the LLVM peeps and I assume that that's a "yes". 
(2) Does the "licm" pass in Binaryen's wasm-opt use LLVM's "licm" pass? 
(3) Does emcc -O3 already include wasm-opt's "licm" pass? I added -s BINARYEN_EXTRA_PASSES=licm, but that didn't seem to have an effect.

I tried directly invoking LLVM's LICM optimisation by passing -mllvm -licm to emcc, but that makes emcc error out. Interestingly, -mllvm -enable-loop-versioning-licm does work, but seems to be an entirely different optimization altogether.

Sadly, the interplay of emcc, clang, wasm-opt, and LLVM's opt utility isn't all too clear when it comes to non-standard clang/LLVM features...

Soeren

Thomas Lively

unread,
Jan 12, 2022, 3:23:57 AM1/12/22
to emscripte...@googlegroups.com
I don’t know about this new LICM optimization in particular, but I can tell you that Binaryen and wasm-opt specifically are completely separate from LLVM, so do not share any LICM code with it. emcc -O3 is also just a wrapper around clang -O3, so it should run the same optimizations that vanilla clang would. I hope that helps you make sense of things!

Alon Zakai

unread,
Jan 12, 2022, 1:05:12 PM1/12/22
to emscripte...@googlegroups.com
You can use bisection to find out exactly where a speedup came from, basically the same as finding a regression,


That would give you a single (and hopefully short) list of commits in a single tool (LLVM or Binaryen, but not both).


Soeren Balko

unread,
Jan 12, 2022, 10:07:51 PM1/12/22
to emscripten-discuss
Thanks for clarifying this for me, Thomas and Alon!

I will try bisecting back to the emsdk commit that introduced the improvement and report back my findings (if any).

Soeren

Reply all
Reply to author
Forward
0 new messages