Skip to content

Commit

Permalink
Rewrite to work around Clang ICE
Browse files Browse the repository at this point in the history
ChangeLog:

	* vir/simd_execution.h (detail::memory_alignment): Adapted from
	original memory_alignment_v constexpr-if implementation.
	(detail::memory_alignment_v): Implement using memory_alignment.
  • Loading branch information
mattkretz committed Oct 26, 2023
1 parent 7df1b16 commit c70f365
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions vir/simd_execution.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,26 @@ case##N:
{};

template <typename V, typename T = typename V::value_type>
inline constexpr std::size_t memory_alignment_v = [] {
if constexpr (stdx::is_simd_v<V>)
return stdx::memory_alignment_v<V, T>;
else if constexpr (requires {
{V::template memory_alignment<T>} -> std::same_as<std::size_t>;
})
return V::template memory_alignment<T>;
else
return alignof(T);
}();
struct memory_alignment
: vir::constexpr_wrapper<alignof(T)>
{};

template <typename V, typename T>
requires (stdx::is_simd_v<V>)
struct memory_alignment<V, T>
: stdx::memory_alignment<V, T>
{};

template <typename V, typename T>
requires (not stdx::is_simd_v<V>) and requires {
{V::template memory_alignment<T>} -> std::same_as<std::size_t>;
}
struct memory_alignment<V, T>
: vir::constexpr_wrapper<V::template memory_alignment<T>>
{};

template <typename V, typename T = typename V::value_type>
inline constexpr std::size_t memory_alignment_v = memory_alignment<V, T>::value;

template <typename V, simd_execution_policy ExecutionPolicy>
struct prologue
Expand Down

0 comments on commit c70f365

Please sign in to comment.