@@ -38,8 +38,7 @@ BUILTIN_CREATE_ENABLER(builtin_enable_suint32, default_ret_type,
38
38
NUM_ARGS, NAME, builtin_enable_integer_t, [](auto... xs) { \
39
39
using ret_ty = \
40
40
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...)); \
43
42
})
44
43
# else
45
44
# define BUILTIN_GENINT(NUM_ARGS, NAME) \
@@ -54,11 +53,10 @@ BUILTIN_CREATE_ENABLER(builtin_enable_suint32, default_ret_type,
54
53
NUM_ARGS, NAME, builtin_enable_integer_t, [](auto... xs) { \
55
54
using ret_ty = \
56
55
detail ::builtin_enable_integer_t< NUM_ARGS# #_TEMPLATE_TYPE>; \
57
- using detail ::builtins ::convert_result; \
58
56
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...)); \
60
58
else \
61
- return convert_result < ret_ty> (__spirv_ocl_u_# #NAME(xs...)); \
59
+ return bit_cast < ret_ty> (__spirv_ocl_u_# #NAME(xs...)); \
62
60
})
63
61
# else
64
62
# 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,
67
65
# if __SYCL_DEVICE_ONLY__
68
66
DEVICE_IMPL_TEMPLATE (ONE_ARG, abs, builtin_enable_integer_t, [](auto x) {
69
67
using ret_ty = detail ::builtin_enable_integer_t< T0> ;
70
- using detail ::builtins ::convert_result;
71
68
if constexpr (std ::is_signed_v< detail ::get_elem_type_t< T0>> )
72
69
// SPIR-V builtin returns unsigned type, SYCL's return type is signed
73
70
// with the following restriction:
74
71
// > The behavior is undefined if the result cannot be represented by
75
72
// > 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));
77
74
else
78
- return convert_result < ret_ty> (__spirv_ocl_u_abs (x));
75
+ return bit_cast < ret_ty> (__spirv_ocl_u_abs (x));
79
76
})
80
77
# else
81
78
BUILTIN_GENINT_SU (ONE_ARG, abs)
@@ -87,25 +84,10 @@ BUILTIN_GENINT_SU(TWO_ARGS, add_sat)
87
84
DEVICE_IMPL_TEMPLATE (
88
85
TWO_ARGS, abs_diff, builtin_enable_integer_t, [](auto... xs) {
89
86
using ret_ty = detail ::builtin_enable_integer_t< T0> ;
90
- using detail ::builtins ::convert_result;
91
87
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...));
107
89
} 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...));
109
91
}
110
92
})
111
93
# else
0 commit comments