Skip to content

Commit aa015f3

Browse files
[NFCI] More convertToOpenCLType-related simplifications (intel#12717)
1 parent 79d775e commit aa015f3

File tree

5 files changed

+141
-319
lines changed

5 files changed

+141
-319
lines changed

sycl/include/sycl/builtins_preview.hpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,13 @@ template <typename T> auto convert_arg(T &&x) {
9595
__attribute__((ext_vector_type(N)))>;
9696
// TODO: We should have this bit_cast impl inside vec::convert.
9797
return bit_cast<result_type>(static_cast<typename no_cv_ref::vector_t>(x));
98-
} else if constexpr (std::is_same_v<no_cv_ref, half>)
99-
return static_cast<half_impl::BIsRepresentationT>(x);
100-
else if constexpr (is_multi_ptr_v<no_cv_ref>) {
101-
return convert_arg(x.get_decorated());
102-
} else if constexpr (is_scalar_arithmetic_v<no_cv_ref>) {
103-
// E.g. on linux: long long -> int64_t (long), or char -> int8_t (signed
104-
// char) and same for unsigned; Windows has long/long long reversed.
105-
// TODO: Inline this scalar impl.
106-
return static_cast<ConvertToOpenCLType_t<no_cv_ref>>(x);
107-
} else if constexpr (std::is_pointer_v<no_cv_ref>) {
108-
using elem_type = remove_decoration_t<std::remove_pointer_t<no_cv_ref>>;
109-
using converted_elem_type =
110-
decltype(convert_arg(std::declval<elem_type>()));
111-
using result_type =
112-
typename DecoratedType<converted_elem_type,
113-
deduce_AS<no_cv_ref>::value>::type *;
114-
return reinterpret_cast<result_type>(x);
11598
} else if constexpr (is_swizzle_v<no_cv_ref>) {
11699
return convert_arg(simplify_if_swizzle_t<no_cv_ref>{x});
117100
} else {
118-
// TODO: should it be unreachable? What can it be?
119-
return std::forward<T>(x);
101+
static_assert(is_scalar_arithmetic_v<no_cv_ref> ||
102+
is_multi_ptr_v<no_cv_ref> || std::is_pointer_v<no_cv_ref> ||
103+
std::is_same_v<no_cv_ref, half>);
104+
return convertToOpenCLType(std::forward<T>(x));
120105
}
121106
}
122107

0 commit comments

Comments
 (0)