Skip to content

Enable SIMD by default? #25945

Open
Open

Description

@kripken

Probably a little early given the state of browser support, but eventually we may want to do this. This would allow the autovectorizer to do things, even without explicit SIMD in the source files.

Looking at our benchmark suite, many benchmarks change size by less than 1%, some growing and some shrinking. A few change by larger amounts: base64 is 9% larger, lzma 7%, memops 3%, skinning 2%, while one shrinks by a lot: poppler by 7%. The last is actually the most realistic codebase, so I'm not sure what the average size change would be.

Only three benchmarks change in timing: skinning is 11% faster (makes sense, as it is a highly-vectorizable loop, and I guess the autovectorizer does well there), poppler is 7% faster (this surprised me but I double-checked), and zlib is 4% faster (ditto). No benchmark gets worse.

Overall there is no clear benefit/loss in size, and a few things speed up nicely, so this seems useful.

I also saw no test failures among the benchmarks. cc @dschuff who had some ideas on testing.

Activity

  1. lindell commented on Dec 15, 2025

    @lindell

    One reason not to do it is that SIMD instructions are not automatically converted to non SIMD instructions for users with CPUs that does not support (the right type of) SIMD. Even if WASM SIMD within the browser is supported.

    https://source.chromium.org/chromium/chromium/src/+/main:v8/src/wasm/function-body-decoder.cc;l=96;drc=db569cd7847d479358bd391a18b2c28393803333

  2. kripken commented on Dec 15, 2025

    @kripken
    MemberAuthor

    Thanks @lindell , good to know! We should definitely wait until browsers have good software fallbacks here.

  3. dschuff commented on Dec 15, 2025

    @dschuff
    Member

    It looks like real SIMD is used for any CPU that supports SSSE3, which goes back to 2006. I wonder if we have any data on how many devices that really is.

  4. dschuff commented on Dec 15, 2025

    @dschuff
    Member

    (Also, given that the number of devices is likely really small, I doubt that there is going to be a lot of work put in by engines to improve scalar fallback for the base SIMD proposal).

  5. sbc100 commented on Dec 15, 2025

    @sbc100
    Collaborator

    This recently came up as part of our llvm-libc experimentation. Specifically llvm-libc's math function can take advantage of at leave FMA, but maybe other SIMD instructions. CC @google-yfyang

    @kripken did you look into recompiling libc / libc++ etc with simd enabled too? I don't if there are any places there that could benefit.

  6. sbc100 commented on Dec 15, 2025

    @sbc100
    Collaborator

    One thing to consider if we do enable this by default is how to handle sysroot issue. Do we:

    1. Build all the sysroot libraries with SIMD enabled then add a lowering pass in binaryen (this is what we have done for more recent features).
    2. Build a separate non-SIMD sysroot (currently we only do this for LTO, wasm64 and PIC).
  7. kripken commented on Dec 15, 2025

    @kripken
    MemberAuthor

    @sbc100 good point, I just compiled with -msimd128, so only benchmark code itself was optimized with SIMD. I'm not sure if we have good benchmark code to stress libc/libc++, actually - we may need new benchmarks for the sysroot.

  8. kleisauke commented on Jun 15, 2026

    @kleisauke
    Collaborator

    It looks like real SIMD is used for any CPU that supports SSSE3, which goes back to 2006.

    Note that the Wasm SIMD SSSE3 codegen was removed with commit v8/v8@48c8e0c in V8, which means SSE4.1 is now required for Wasm SIMD on x64 CPUs (at least in Chromium-based browsers, I haven't checked other engines).
    https://github.com/v8/v8/blob/15.1.106/src/wasm/function-body-decoder-impl.h#L5146
    https://github.com/v8/v8/blob/15.1.106/src/wasm/function-body-decoder.cc#L95
    https://github.com/v8/v8/blob/15.1.106/src/codegen/x64/assembler-x64.cc#L97

  9. dschuff commented on Jun 15, 2026

    @dschuff
    Member

    Yeah, that's an interesting wrinkle. Ultimately the calculus would be similar to what we do with browser versions; we want to improve the experience for most people by moving the default to newer features over time while leaving as few users as possible unsupported by the default (knowing that many developers will use the default). And we want to give developers ways to support those not-supported-by-default users themselves if we can. Hardware features are of course adopted much more slowly than browser versions, but we are also talking about much older hardware (and presumably fewer users?). It looks like SSE4.1 was introduced with Penryn (65nm Core 2) in 2007, and the last architectures to lack support (the 32nm clover trail Atom processors) were replaced in 2013.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions