* [PATCH] libstdc++: Silence irrelevant warnings in <experimental/simd>
@ 2024-04-22 15:29 Matthias Kretz
2024-04-22 16:06 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kretz @ 2024-04-22 15:29 UTC (permalink / raw)
To: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 3467 bytes --]
Tested on x86_64-linux-gnu, powerpc64le-linux-gnu, aarch64-linux-gnu, arm-
linux-gnueabihf
OK for trunk and backports?
----------------------------- 8< ---------------------------------
Avoid
-Wnarrowing in C code;
-Wtautological-compare in unconditional static_assert (necessary for
faking a dependency on a template parameter)
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:
* include/experimental/bits/simd.h: Ignore -Wnarrowing for
arm_neon.h.
(__int_for_sizeof): Replace tautological compare with checking
for invalid template parameter value.
* include/experimental/bits/simd_builtin.h (__extract_part):
Remove tautological compare by combining two static_assert.
---
libstdc++-v3/include/experimental/bits/simd.h | 8 +++++++-
libstdc++-v3/include/experimental/bits/simd_builtin.h | 3 +--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/
include/experimental/bits/simd.h
index 03c2e17a326..6ef9c955cfa 100644
--- a/libstdc++-v3/include/experimental/bits/simd.h
+++ b/libstdc++-v3/include/experimental/bits/simd.h
@@ -44,7 +44,12 @@
#if _GLIBCXX_SIMD_X86INTRIN
#include <x86intrin.h>
#elif _GLIBCXX_SIMD_HAVE_NEON
+#pragma GCC diagnostic push
+// narrowing conversion of '__a' from 'uint64_t' {aka 'long long unsigned
int'} to
+// 'int64x1_t' {aka 'long long int'} [-Wnarrowing]
+#pragma GCC diagnostic ignored "-Wnarrowing"
#include <arm_neon.h>
+#pragma GCC diagnostic pop
#endif
#if _GLIBCXX_SIMD_HAVE_SVE
#include <arm_sve.h>
@@ -598,6 +603,7 @@ struct __is_bitmask
constexpr auto
__int_for_sizeof()
{
+ static_assert(_Bytes > 0);
if constexpr (_Bytes == sizeof(int))
return int();
#ifdef __clang__
@@ -663,7 +669,7 @@ struct _Ip
return _Ip{};
}
else
- static_assert(_Bytes != _Bytes, "this should be unreachable");
+ static_assert(_Bytes == 0, "this should be unreachable");
}
#pragma GCC diagnostic pop
diff --git a/libstdc++-v3/include/experimental/bits/simd_builtin.h b/libstdc+
+-v3/include/experimental/bits/simd_builtin.h
index af0c4886108..49c7c7e1c70 100644
--- a/libstdc++-v3/include/experimental/bits/simd_builtin.h
+++ b/libstdc++-v3/include/experimental/bits/simd_builtin.h
@@ -278,8 +278,7 @@ __extract_part(const _SimdWrapper<_Tp, _Np> __x)
__extract_part(const _SimdWrapper<bool, _Np> __x)
{
static_assert(_Combine == 1, "_Combine != 1 not implemented");
- static_assert(__have_avx512f && _Np == _Np);
- static_assert(_Total >= 2 && _Index + _Combine <= _Total && _Index >= 0);
+ static_assert(__have_avx512f && _Total >= 2 && _Index + _Combine <=
_Total && _Index >= 0);
return __x._M_data >> (_Index * _Np / _Total);
}
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
stdₓ::simd
──────────────────────────────────────────────────────────────────────────
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libstdc++: Silence irrelevant warnings in <experimental/simd>
2024-04-22 15:29 [PATCH] libstdc++: Silence irrelevant warnings in <experimental/simd> Matthias Kretz
@ 2024-04-22 16:06 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2024-04-22 16:06 UTC (permalink / raw)
To: Matthias Kretz; +Cc: gcc-patches, libstdc++
On Mon, 22 Apr 2024 at 16:30, Matthias Kretz <m.kretz@gsi.de> wrote:
>
> Tested on x86_64-linux-gnu, powerpc64le-linux-gnu, aarch64-linux-gnu, arm-
> linux-gnueabihf
>
> OK for trunk and backports?
OK, thanks
>
> ----------------------------- 8< ---------------------------------
>
>
> Avoid
> -Wnarrowing in C code;
> -Wtautological-compare in unconditional static_assert (necessary for
> faking a dependency on a template parameter)
>
> Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
>
> libstdc++-v3/ChangeLog:
>
> * include/experimental/bits/simd.h: Ignore -Wnarrowing for
> arm_neon.h.
> (__int_for_sizeof): Replace tautological compare with checking
> for invalid template parameter value.
> * include/experimental/bits/simd_builtin.h (__extract_part):
> Remove tautological compare by combining two static_assert.
> ---
> libstdc++-v3/include/experimental/bits/simd.h | 8 +++++++-
> libstdc++-v3/include/experimental/bits/simd_builtin.h | 3 +--
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/
> include/experimental/bits/simd.h
> index 03c2e17a326..6ef9c955cfa 100644
> --- a/libstdc++-v3/include/experimental/bits/simd.h
> +++ b/libstdc++-v3/include/experimental/bits/simd.h
> @@ -44,7 +44,12 @@
> #if _GLIBCXX_SIMD_X86INTRIN
> #include <x86intrin.h>
> #elif _GLIBCXX_SIMD_HAVE_NEON
> +#pragma GCC diagnostic push
> +// narrowing conversion of '__a' from 'uint64_t' {aka 'long long unsigned
> int'} to
> +// 'int64x1_t' {aka 'long long int'} [-Wnarrowing]
> +#pragma GCC diagnostic ignored "-Wnarrowing"
> #include <arm_neon.h>
> +#pragma GCC diagnostic pop
> #endif
> #if _GLIBCXX_SIMD_HAVE_SVE
> #include <arm_sve.h>
> @@ -598,6 +603,7 @@ struct __is_bitmask
> constexpr auto
> __int_for_sizeof()
> {
> + static_assert(_Bytes > 0);
> if constexpr (_Bytes == sizeof(int))
> return int();
> #ifdef __clang__
> @@ -663,7 +669,7 @@ struct _Ip
> return _Ip{};
> }
> else
> - static_assert(_Bytes != _Bytes, "this should be unreachable");
> + static_assert(_Bytes == 0, "this should be unreachable");
> }
> #pragma GCC diagnostic pop
>
> diff --git a/libstdc++-v3/include/experimental/bits/simd_builtin.h b/libstdc+
> +-v3/include/experimental/bits/simd_builtin.h
> index af0c4886108..49c7c7e1c70 100644
> --- a/libstdc++-v3/include/experimental/bits/simd_builtin.h
> +++ b/libstdc++-v3/include/experimental/bits/simd_builtin.h
> @@ -278,8 +278,7 @@ __extract_part(const _SimdWrapper<_Tp, _Np> __x)
> __extract_part(const _SimdWrapper<bool, _Np> __x)
> {
> static_assert(_Combine == 1, "_Combine != 1 not implemented");
> - static_assert(__have_avx512f && _Np == _Np);
> - static_assert(_Total >= 2 && _Index + _Combine <= _Total && _Index >= 0);
> + static_assert(__have_avx512f && _Total >= 2 && _Index + _Combine <=
> _Total && _Index >= 0);
> return __x._M_data >> (_Index * _Np / _Total);
> }
>
> --
> ──────────────────────────────────────────────────────────────────────────
> Dr. Matthias Kretz https://mattkretz.github.io
> GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
> stdₓ::simd
> ──────────────────────────────────────────────────────────────────────────
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-22 16:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22 15:29 [PATCH] libstdc++: Silence irrelevant warnings in <experimental/simd> Matthias Kretz
2024-04-22 16:06 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).