Skip to content

Commit 82a37aa

Browse files
authored
Remove XSIMD_IF_CONSTEXPR macros, use if constexpr instead (#1382)
* Remove XSIMD_IF_CONSTEXPR macros, use if constexpr instead * Remove XIMSD_NO_DISCARD, use [[nodiscard]] instead * Fixed linter
1 parent ea590d5 commit 82a37aa

26 files changed

Lines changed: 824 additions & 854 deletions

docs/Doxyfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ WARN_AS_ERROR = NO
4646
ENABLE_PREPROCESSING = YES
4747
MACRO_EXPANSION = YES
4848
EXPAND_ONLY_PREDEF = YES
49-
PREDEFINED = XSIMD_NO_DISCARD= \
50-
XSIMD_INLINE=inline \
49+
PREDEFINED = XSIMD_INLINE=inline \
5150
DOXYGEN_SHOULD_SKIP_THIS=

docs/source/vectorized_code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ One that is simple and compiles on all platforms is using C++17 ``if constexpr``
106106
xsimd::batch<int8_t, Arch> const& y
107107
) -> xsimd::batch<uint8_t, Arch> {
108108
// Dedicated instruction dispatch at compile time
109-
if constexpr(std::is_same_v<Arch, xsimd::avx2>){
109+
if constexpr (std::is_same_v<Arch, xsimd::avx2>){
110110
// Automatic conversion back and forth between xsimd::batch and native types
111111
return _mm256_sign_epi8(x, y);
112112
// When compiler complains we can be more explicit

include/xsimd/arch/common/xsimd_common_bit.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace xsimd
5757
#if XSIMD_HAS_BUILTIN(__builtin_popcountg)
5858
return __builtin_popcountg(x);
5959
#else
60-
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
60+
if constexpr (sizeof(T) == 1)
6161
{
6262
#if XSIMD_HAS_BUILTIN(__builtin_popcount)
6363
return __builtin_popcount(x);
@@ -68,7 +68,7 @@ namespace xsimd
6868
return ((uint64_t)x * 0x200040008001ULL & 0x111111111111111ULL) % 0xf;
6969
#endif
7070
}
71-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
71+
else if constexpr (sizeof(T) == 2)
7272
{
7373
#if XSIMD_HAS_BUILTIN(__builtin_popcount)
7474
return __builtin_popcount(x);
@@ -85,7 +85,7 @@ namespace xsimd
8585
+ (((v & 0xfff000) >> 12) * msb12 & mask5) % 0x1f;
8686
#endif
8787
}
88-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
88+
else if constexpr (sizeof(T) == 4)
8989
{
9090
#if XSIMD_HAS_BUILTIN(__builtin_popcount)
9191
return __builtin_popcount(x);
@@ -132,7 +132,7 @@ namespace xsimd
132132
if (x == 0)
133133
return sizeof(T) * CHAR_BIT;
134134

135-
XSIMD_IF_CONSTEXPR(sizeof(T) <= 4)
135+
if constexpr (sizeof(T) <= 4)
136136
{
137137
#if XSIMD_HAS_BUILTIN(__builtin_clz)
138138
return __builtin_clz((unsigned int)x) - (4 - sizeof(T)) * CHAR_BIT;
@@ -144,11 +144,11 @@ namespace xsimd
144144
x |= x >> 1;
145145
x |= x >> 2;
146146
x |= x >> 4;
147-
XSIMD_IF_CONSTEXPR(sizeof(T) >= 2)
147+
if constexpr (sizeof(T) >= 2)
148148
{
149149
x |= x >> 8;
150150
}
151-
XSIMD_IF_CONSTEXPR(sizeof(T) >= 4)
151+
if constexpr (sizeof(T) >= 4)
152152
{
153153
x |= x >> 16;
154154
}
@@ -192,7 +192,7 @@ namespace xsimd
192192
if (x == 0)
193193
return sizeof(T) * CHAR_BIT;
194194

195-
XSIMD_IF_CONSTEXPR(sizeof(T) <= 4)
195+
if constexpr (sizeof(T) <= 4)
196196
{
197197
#if XSIMD_HAS_BUILTIN(__builtin_ctz)
198198
return __builtin_ctz((unsigned int)x);

include/xsimd/arch/common/xsimd_common_memory.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -655,27 +655,27 @@ namespace xsimd
655655
static_assert(bsize == batch<T, A>::size, "valid shuffle");
656656

657657
// Detect common patterns
658-
XSIMD_IF_CONSTEXPR(detail::is_swizzle_fst(bsize, Indices...))
658+
if constexpr (detail::is_swizzle_fst(bsize, Indices...))
659659
{
660660
return swizzle(x, batch_constant<ITy, A, ((Indices >= bsize) ? 0 /* never happens */ : Indices)...>());
661661
}
662662

663-
XSIMD_IF_CONSTEXPR(detail::is_swizzle_snd(bsize, Indices...))
663+
if constexpr (detail::is_swizzle_snd(bsize, Indices...))
664664
{
665665
return swizzle(y, batch_constant<ITy, A, ((Indices >= bsize) ? (Indices - bsize) : 0 /* never happens */)...>());
666666
}
667667

668-
XSIMD_IF_CONSTEXPR(detail::is_zip_lo(bsize, Indices...))
668+
if constexpr (detail::is_zip_lo(bsize, Indices...))
669669
{
670670
return zip_lo(x, y);
671671
}
672672

673-
XSIMD_IF_CONSTEXPR(detail::is_zip_hi(bsize, Indices...))
673+
if constexpr (detail::is_zip_hi(bsize, Indices...))
674674
{
675675
return zip_hi(x, y);
676676
}
677677

678-
XSIMD_IF_CONSTEXPR(detail::is_select(bsize, Indices...))
678+
if constexpr (detail::is_select(bsize, Indices...))
679679
{
680680
return select(batch_bool_constant<T, A, (Indices < bsize)...>(), x, y);
681681
}

0 commit comments

Comments
 (0)