Put SIMD perf warnings behind a flag It's not always realistic to update your compiler, and these warings constantly flood the terminal if you can't. Put them behind a flag. We can always turn the flag back on locally to check a specific target. Diffs= 12285f625 Put SIMD perf warnings behind a flag (#4861)
diff --git a/.rive_head b/.rive_head index 726c613..5bc4085 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -157a399d23a0f5ea729ad50661f88eea8f84eee1 +12285f625ff69c6b21528d93b3b665d9b0b9f8be
diff --git a/include/rive/math/simd.hpp b/include/rive/math/simd.hpp index 2ee5a4e..7f45c24 100644 --- a/include/rive/math/simd.hpp +++ b/include/rive/math/simd.hpp
@@ -14,6 +14,8 @@ #ifndef _RIVE_SIMD_HPP_ #define _RIVE_SIMD_HPP_ +// #define RIVE_SIMD_PERF_WARNINGS + #include "rive/rive_types.hpp" #include <cassert> #include <limits> @@ -50,7 +52,9 @@ #else // gvec needs to be polyfilled with templates. +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: ext_vector_type not supported. Consider using clang.") +#endif #include "simd_gvec_polyfill.hpp" #endif @@ -71,7 +75,9 @@ #if __has_builtin(__builtin_reduce_or) return __builtin_reduce_or(x); #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: __builtin_reduce_or() not supported. Consider updating clang.") +#endif // This particular logic structure gets decent codegen in clang. for (int i = 0; i < N; ++i) { @@ -88,7 +94,9 @@ #if __has_builtin(__builtin_reduce_and) return __builtin_reduce_and(x); #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: __builtin_reduce_and() not supported. Consider updating clang.") +#endif // In vector, true is represented by -1 exactly, so we use ~x for "not". return !any(~x); #endif @@ -118,7 +126,9 @@ // The '?:' operator supports a vector condition beginning in clang 13. return _if ? _then : _else; #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: vectorized '?:' operator not supported. Consider updating clang.") +#endif gvec<T, N> ret{}; for (int i = 0; i < N; ++i) ret[i] = _if[i] ? _then[i] : _else[i]; @@ -133,7 +143,9 @@ #if __has_builtin(__builtin_elementwise_min) return __builtin_elementwise_min(a, b); #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: __builtin_elementwise_min() not supported. Consider updating clang.") +#endif // Generate the same behavior for NaN as the SIMD builtins. (isnan() is a no-op for int types.) return if_then_else(b < a || isnan(a), b, a); #endif @@ -146,7 +158,9 @@ #if __has_builtin(__builtin_elementwise_max) return __builtin_elementwise_max(a, b); #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: __builtin_elementwise_max() not supported. Consider updating clang.") +#endif // Generate the same behavior for NaN as the SIMD builtins. (isnan() is a no-op for int types.) return if_then_else(a < b || isnan(a), b, a); #endif @@ -171,7 +185,9 @@ #if __has_builtin(__builtin_elementwise_abs) return __builtin_elementwise_abs(x); #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: __builtin_elementwise_abs() not supported. Consider updating clang.") +#endif return if_then_else(x < (T)0, -x, x); // Negate on the "true" side so we never negate NaN. #endif } @@ -204,8 +220,10 @@ #if __has_builtin(__builtin_elementwise_floor) return __builtin_elementwise_floor(x); #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message( \ "performance: __builtin_elementwise_floor() not supported. Consider updating clang.") +#endif for (int i = 0; i < N; ++i) x[i] = floorf(x[i]); return x; @@ -217,7 +235,9 @@ #if __has_builtin(__builtin_elementwise_ceil) return __builtin_elementwise_ceil(x); #else +#ifdef RIVE_SIMD_PERF_WARNINGS #pragma message("performance: __builtin_elementwise_ceil() not supported. Consider updating clang.") +#endif for (int i = 0; i < N; ++i) x[i] = ceilf(x[i]); return x;