-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup useless/non-constexpr branchs #2025
Changes from 5 commits
82d0266
80fe8a2
90174f1
b05416f
c8ed87f
c6ff5b3
93b76d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,17 +59,17 @@ namespace eve | |
struct broadcast_lane_t | ||
{ | ||
template<simd_value T, std::ptrdiff_t G, std::ptrdiff_t I> | ||
static constexpr auto pattern(eve::as<T>, eve::fixed<G>, eve::index_t<I>) | ||
static consteval auto pattern(eve::as<T>, eve::fixed<G>, eve::index_t<I>) | ||
{ | ||
static_assert(I < T::size() / G); | ||
return eve::fix_pattern<T::size() / G>([](int, int) { return I; }); | ||
} | ||
|
||
template<simd_value T, std::ptrdiff_t G, std::ptrdiff_t I> | ||
static constexpr std::ptrdiff_t level(eve::as<T> tgt, eve::fixed<G> g, eve::index_t<I> i) | ||
static consteval std::ptrdiff_t level(eve::as<T> tgt, eve::fixed<G> g, eve::index_t<I> i) | ||
{ | ||
const std::size_t reg_size = sizeof(element_type_t<T>) * T::size(); | ||
const std::ptrdiff_t g_size = sizeof(element_type_t<T>) * G; | ||
constexpr std::size_t reg_size = sizeof(element_type_t<T>) * T::size(); | ||
constexpr std::ptrdiff_t g_size = sizeof(element_type_t<T>) * G; | ||
|
||
if constexpr( eve::has_aggregated_abi_v<T> ) | ||
{ | ||
|
@@ -80,47 +80,47 @@ struct broadcast_lane_t | |
else if constexpr( current_api >= vmx ) return 2; | ||
else if constexpr( current_api >= sve ) | ||
{ | ||
if( !logical_value<T> ) return g_size > 8 ? 3 : 2; | ||
if( G == 1 ) return 4; | ||
if( g_size <= 8 ) return 6; | ||
return 7; | ||
if constexpr ( !logical_value<T> ) return g_size > 8 ? 3 : 2; | ||
else if constexpr ( G == 1 ) return 4; | ||
else if constexpr ( g_size <= 8 ) return 6; | ||
else return 7; | ||
} | ||
else if constexpr( current_api >= neon ) | ||
{ | ||
if( current_api >= asimd ) return 2; | ||
if( reg_size <= 8 ) return 2; | ||
return 4; | ||
if constexpr ( current_api >= asimd ) return 2; | ||
else if constexpr ( reg_size <= 8 ) return 2; | ||
else return 4; | ||
} | ||
|
||
// x86 | ||
|
||
if (current_api == avx512 && logical_value<T>) | ||
if constexpr (current_api == avx512 && logical_value<T>) | ||
{ | ||
if (G == 1) return 4; | ||
return level(detail::mask_type(tgt), g, i) + 4; | ||
if constexpr (G == 1) return 4; | ||
else return level(detail::mask_type(tgt), g, i) + 4; | ||
} | ||
|
||
if (reg_size == 64) | ||
else if constexpr (reg_size == 64) | ||
{ | ||
if (g_size >= 16) return 2; | ||
if (g_size >= 2) return 3; | ||
return 4; | ||
if constexpr (g_size >= 16) return 2; | ||
else if constexpr (g_size >= 2) return 3; | ||
else return 4; | ||
} | ||
|
||
if (reg_size == 32) | ||
else if constexpr (reg_size == 32) | ||
{ | ||
if (g_size >= 16) return 2; | ||
if (current_api == avx) return 4; | ||
if (g_size >= 8) return 2; | ||
if (g_size >= 4) return 3; | ||
if (g_size >= 2 && current_api == avx512) return 3; | ||
return 4; | ||
if constexpr (g_size >= 16) return 2; | ||
if constexpr (current_api == avx) return 4; | ||
if constexpr (g_size >= 8) return 2; | ||
if constexpr (g_size >= 4) return 3; | ||
if constexpr (g_size >= 2 && current_api == avx512) return 3; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you see - now you push things to comile time switching instead of just evaluating. I don't know how this works under the hood, but it seems worse. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you expand on that a little bit ? I don't think I quite get it. |
||
else return 4; | ||
} | ||
else | ||
{ | ||
if constexpr ( g_size >= 4 ) return 2; | ||
else if constexpr ( g_size == 2 && reg_size <= 8 ) return 2; | ||
else if constexpr ( current_api >= ssse3 ) return 3; | ||
else return 4; | ||
} | ||
|
||
if ( g_size >= 4 ) return 2; | ||
if ( g_size == 2 && reg_size <= 8 ) return 2; | ||
if ( current_api >= ssse3 ) return 3; | ||
return 4; | ||
} | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same story here - we don't want the ifs to be constexpr when t doesn't have to. And I don't like consteval for no reason.