Skip to content

Commit 12a11ac

Browse files
Highwaycopybara-github
authored andcommitted
Copybara import of the project:
-- 1c113ee by landerlyoung <landerlyoung@gmail.com>: Optimize auto-detection of `HWY_ARCH_WASM` target discussed in #2831 PiperOrigin-RevId: 861850021
1 parent 979eb41 commit 12a11ac

File tree

3 files changed

+1
-19
lines changed

3 files changed

+1
-19
lines changed

g3doc/quick_reference.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,6 @@ You can detect and influence the set of supported targets:
390390
order to test each supported target. Calling with `b == 0` restores the
391391
normal `SupportedTargets` behavior.
392392

393-
**Note on `HWY_ARCH_WASM`**. The target is automatically detected and enabled;
394-
compiler flags such as -msimd128 are not required. This auto-detection
395-
behavior is consistent with other architectures (e.g., AVX2, NEON).
396-
Developers wishing to disable the `HWY_ARCH_WASM` target (e.g., to increase
397-
browser compatibility, or workaround compiler bugs) should use the
398-
`HWY_DISABLED_TARGETS` macro.
399-
400393
## Operations
401394

402395
In the following, the argument or return type `V` denotes a vector with `N`
@@ -2924,13 +2917,6 @@ binary will likely crash. This can only happen if:
29242917
also not supported by the current CPU, and baseline targets (in particular
29252918
`HWY_SCALAR`) were explicitly disabled.
29262919
2927-
**Note on WebAssembly:**: The browser validates the WebAssembly module during
2928-
instantiation when using `WebAssembly.instantiate` APIs. If SIMD features are
2929-
unsupported, the entire module is rejected. Therefore, dynamic dispatch between
2930-
targets (such as `HWY_SCALAR` and `HWY_WASM`) based on runtime feature detection
2931-
is not feasible, unlike with native targets. Developers should configure the
2932-
`HWY_ARCH_WASM` target at compile time using the `HWY_DISABLED_TARGETS` macro.
2933-
29342920
## Advanced configuration macros
29352921
29362922
The following macros govern which targets to generate. Unless specified

hwy/detect_compiler_arch.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@
290290
#define HWY_ARCH_ARM_OLD 0
291291
#endif
292292

293-
// Note: The WASM target is auto-detected and enabled; compiler flags like
294-
// "-msimd128" are not required. This behavior is consistent with other
295-
// architectures (e.g., AVX2, NEON). To disable HWY_ARCH_WASM, use the
296-
// HWY_DISABLED_TARGETS macro. For details, see the quick reference manual.
297293
#if defined(__EMSCRIPTEN__) || defined(__wasm__) || defined(__WASM__)
298294
#define HWY_ARCH_WASM 1
299295
#else

hwy/detect_targets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@
433433
// Also check HWY_ARCH to ensure that simulating unknown platforms ends up with
434434
// HWY_TARGET == HWY_BASELINE_SCALAR.
435435

436-
#if HWY_ARCH_WASM
436+
#if HWY_ARCH_WASM && defined(__wasm_simd128__)
437437
#if defined(HWY_WANT_WASM2)
438438
#define HWY_BASELINE_WASM HWY_WASM_EMU256
439439
#else

0 commit comments

Comments
 (0)