@@ -38,8 +38,7 @@ BUILTIN_CREATE_ENABLER(builtin_enable_suint32, default_ret_type,
3838 NUM_ARGS, NAME, builtin_enable_integer_t, [](auto... xs) { \
3939 using ret_ty = \
4040 detail ::builtin_enable_integer_t< NUM_ARGS# #_TEMPLATE_TYPE>; \
41- return detail ::builtins ::convert_result< ret_ty> ( \
42- __spirv_ocl_# #NAME(xs...)); \
41+ return bit_cast< ret_ty> (__spirv_ocl_# #NAME(xs...)); \
4342 })
4443# else
4544# define BUILTIN_GENINT(NUM_ARGS, NAME) \
@@ -54,11 +53,10 @@ BUILTIN_CREATE_ENABLER(builtin_enable_suint32, default_ret_type,
5453 NUM_ARGS, NAME, builtin_enable_integer_t, [](auto... xs) { \
5554 using ret_ty = \
5655 detail ::builtin_enable_integer_t< NUM_ARGS# #_TEMPLATE_TYPE>; \
57- using detail ::builtins ::convert_result; \
5856 if constexpr (std ::is_signed_v< detail ::get_elem_type_t< T0>> ) \
59- return convert_result < ret_ty> (__spirv_ocl_s_# #NAME(xs...)); \
57+ return bit_cast < ret_ty> (__spirv_ocl_s_# #NAME(xs...)); \
6058 else \
61- return convert_result < ret_ty> (__spirv_ocl_u_# #NAME(xs...)); \
59+ return bit_cast < ret_ty> (__spirv_ocl_u_# #NAME(xs...)); \
6260 })
6361# else
6462# define BUILTIN_GENINT_SU(NUM_ARGS, NAME) BUILTIN_GENINT(NUM_ARGS, NAME)
@@ -67,15 +65,14 @@ BUILTIN_CREATE_ENABLER(builtin_enable_suint32, default_ret_type,
6765# if __SYCL_DEVICE_ONLY__
6866DEVICE_IMPL_TEMPLATE (ONE_ARG, abs, builtin_enable_integer_t, [](auto x) {
6967 using ret_ty = detail ::builtin_enable_integer_t< T0> ;
70- using detail ::builtins ::convert_result;
7168 if constexpr (std ::is_signed_v< detail ::get_elem_type_t< T0>> )
7269 // SPIR-V builtin returns unsigned type, SYCL's return type is signed
7370 // with the following restriction:
7471 // > The behavior is undefined if the result cannot be represented by
7572 // > the return type
76- return convert_result < ret_ty> (bit_cast < T0 > ( __spirv_ocl_s_abs (x) ));
73+ return bit_cast < ret_ty> (__spirv_ocl_s_abs (x));
7774 else
78- return convert_result < ret_ty> (__spirv_ocl_u_abs (x));
75+ return bit_cast < ret_ty> (__spirv_ocl_u_abs (x));
7976})
8077# else
8178BUILTIN_GENINT_SU (ONE_ARG, abs)
@@ -87,25 +84,10 @@ BUILTIN_GENINT_SU(TWO_ARGS, add_sat)
8784DEVICE_IMPL_TEMPLATE (
8885 TWO_ARGS, abs_diff, builtin_enable_integer_t, [](auto... xs) {
8986 using ret_ty = detail ::builtin_enable_integer_t< T0> ;
90- using detail ::builtins ::convert_result;
9187 if constexpr (std ::is_signed_v< detail ::get_elem_type_t< T0>> ) {
92- // SPIRV built-in returns [vector of] unsigned type(s).
93- auto ret = __spirv_ocl_s_abs_diff (xs...);
94- if constexpr (detail ::is_vec_v< T0> ) {
95- // SYCL 2020 revision 8's abs_diff returns T0 (or corresponding vec in
96- // case of a swizzle). The only way to produce signed ext_vector_type
97- // from unsigned is with C-style case. Also note that element type of
98- // sycl::vec and ext_vector_type might be different, e.g.
99- // sycl::vec<char, N>::vector_t is
100- // signed char __attribute__((ext_vector_type(N))).
101- //
102- // TODO: Shouldn't be different from "abs" above.
103- return convert_result< ret_ty> ((typename T0 ::vector_t)(ret));
104- } else {
105- return convert_result< ret_ty> (ret);
106- }
88+ return bit_cast< ret_ty> (__spirv_ocl_s_abs_diff (xs...));
10789 } else {
108- return convert_result < ret_ty> (__spirv_ocl_u_abs_diff (xs...));
90+ return bit_cast < ret_ty> (__spirv_ocl_u_abs_diff (xs...));
10991 }
11092 })
11193# else
0 commit comments