summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-01-17 11:49:30 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 11:47:40 +0100
commitc9b11379ee3e282a82a53995b64160aead8bfa94 (patch)
tree221602a7d63671797c3f0605bd103f1bab700bcf
parent77b4a1f3692e96b5a458d97cbb14739c4b0b2815 (diff)
downloadqtwebengine-chromium-c9b11379ee3e282a82a53995b64160aead8bfa94.tar.gz
Use clang builtins in gcc when available
__builtin_convertvector since gcc 9 __builtin_shufflevector since gcc 12 Change-Id: I51f056473342054203016e87b4e048d0e8139f11 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
-rw-r--r--chromium/third_party/skia/include/private/SkVx.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/chromium/third_party/skia/include/private/SkVx.h b/chromium/third_party/skia/include/private/SkVx.h
index 74cdabffe2d..2fcc42ed3a3 100644
--- a/chromium/third_party/skia/include/private/SkVx.h
+++ b/chromium/third_party/skia/include/private/SkVx.h
@@ -558,8 +558,8 @@ SI Vec<1,D> cast(const Vec<1,S>& src) { return (D)src.val; }
template <typename D, int N, typename S>
SI Vec<N,D> cast(const Vec<N,S>& src) {
-#if SKVX_USE_SIMD && defined(__clang__)
- return to_vec(__builtin_convertvector(to_vext(src), VExt<N,D>));
+#if SKVX_USE_SIMD && (defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9))
+ return to_vec<N,D>(__builtin_convertvector(to_vext(src), VExt<N,D>));
#else
return join(cast<D>(src.lo), cast<D>(src.hi));
#endif
@@ -594,10 +594,22 @@ SINT Vec<N,T> pin(const Vec<N,T>& x, const Vec<N,T>& lo, const Vec<N,T>& hi) {
// The only real restriction is that the output also be a legal N=power-of-two sknx::Vec.
template <int... Ix, int N, typename T>
SI Vec<sizeof...(Ix),T> shuffle(const Vec<N,T>& x) {
-#if SKVX_USE_SIMD && defined(__clang__)
+#if SKVX_USE_SIMD && (defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 12))
// TODO: can we just always use { x[Ix]... }?
return to_vec<sizeof...(Ix),T>(__builtin_shufflevector(to_vext(x), to_vext(x), Ix...));
#else
+#if !defined(SKNX_NO_SIMD) && defined(__GNUC__)
+ if constexpr(sizeof...(Ix) == N) {
+ if constexpr(sizeof(T) == 1)
+ return to_vec<N,T>(__builtin_shuffle(to_vext(x), VExt<N,char>{Ix...}));
+ else if constexpr(sizeof(T) == 2)
+ return to_vec<N,T>(__builtin_shuffle(to_vext(x), VExt<N,short>{Ix...}));
+ else if constexpr(sizeof(T) == 4)
+ return to_vec<N,T>(__builtin_shuffle(to_vext(x), VExt<N,int>{Ix...}));
+ else if constexpr(sizeof(T) == 8)
+ return to_vec<N,T>(__builtin_shuffle(to_vext(x), VExt<N,long long>{Ix...}));
+ } else
+#endif
return { x[Ix]... };
#endif
}