simd-everywhere / simde

Implementations of SIMD instruction sets for systems which don't natively support them.
https://simd-everywhere.github.io/blog/
MIT License
2.28k stars 237 forks source link

Warning/error when using simde on clang 17 #1151

Closed SoniEx2 closed 4 months ago

SoniEx2 commented 4 months ago

simde version: 0.8.0 clang version: 17.0.6 target: x86_64-pc-linux-gnu

code:

#include <simde/wasm/simd128.h>

simde_v128_t w2c_simd__lane__0__wasm_v8x16_swizzle_0(simde_v128_t var_p0, simde_v128_t var_p1) {
  return simde_wasm_i8x16_swizzle(var_p0, var_p1);
}

compile command:

clang -I../../third_party/simde -c simd_lane.0.c -o simd_lane.0.o -O2 -Wall -Werror -std=c99

This produces the error/warning:

simd_lane.0.c:3:14: error: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Werror,-Wpass-failed=transform-warning]
    3 | simde_v128_t w2c_simd__lane__0__wasm_v8x16_swizzle_0(simde_v128_t var_p0, simde_v128_t var_p1) {
      |              ^
1 error generated.

Which seems kinda odd honestly. Minified from WebAssembly/wabt#2403

We can't tell if it's a "holding the compiler wrong" issue, or simde is providing the wrong hints to the compiler somehow, or what's going on here. Any ideas?

mr-c commented 4 months ago

Huh. I don't understand the error. Does it go away if you turn off the SSSE3 implementation? Alternatively, does it get better if you compile with -mssse3 or -march=native?

mr-c commented 4 months ago

Also, it is very recommended to compile using -fopenmp-simd -DSIMDE_ENABLE_OPENMP on Clang version 6+ and GGC version 4.9+

SoniEx2 commented 4 months ago

it does not go away with -DSIMDE_NO_NATIVE, and openmp-simd doesn't help either.

so presumably the SIMDE_VECTORIZE now warns when the vectorization isn't supported?

mr-c commented 4 months ago

so presumably the SIMDE_VECTORIZE now warns when the vectorization isn't supported?

That could be. I guess one could check with the Compiler Explorer to see if that code normally is vectorized on other compilers.

SoniEx2 commented 4 months ago

we believe we can safely use -Wno-pass-failed (unfortunately we can't use -march=native as that breaks cross-compiles, ah well). thanks for the help!

from what we could gather, clang doesn't appear to have a way to suppress the warning at the pragma site, which seems pretty reasonable in the general case honestly but we aren't testing for optimizations in the wabt test suite, we're just testing for correctness.