@@ -98,9 +98,12 @@ template <typename TRes, typename TArg, int SZ>
9898ESIMD_NODEBUG ESIMD_INLINE simd<TRes, SZ>
9999__esimd_abs_common_internal (simd<TArg, SZ> src0) {
100100 simd<TArg, SZ> Result;
101- if constexpr (detail::is_generic_floating_point_v<TArg>)
102- Result = simd<TArg, SZ>(__spirv_ocl_fabs<TArg, SZ>(src0.data ()));
103- else
101+ if constexpr (detail::is_generic_floating_point_v<TArg>) {
102+ using CppT = __ESIMD_DNS::element_type_traits<TArg>::EnclosingCppT;
103+ Result =
104+ __ESIMD_DNS::convert_vector<TArg, CppT, SZ>(__spirv_ocl_fabs<CppT, SZ>(
105+ __ESIMD_DNS::convert_vector<CppT, TArg, SZ>(src0.data ())));
106+ } else
104107 Result = simd<TArg, SZ>(__spirv_ocl_s_abs<TArg, SZ>(src0.data ()));
105108 return convert<TRes>(Result);
106109}
@@ -184,8 +187,12 @@ template <typename T, int SZ, class Sat = saturation_off_tag>
184187__ESIMD_API simd<T, SZ>(max)(simd<T, SZ> src0, simd<T, SZ> src1, Sat sat = {}) {
185188 constexpr bool is_sat = std::is_same_v<Sat, saturation_on_tag>;
186189
187- if constexpr (std::is_floating_point<T>::value) {
188- auto Result = __spirv_ocl_fmax<T, SZ>(src0.data (), src1.data ());
190+ if constexpr (detail::is_generic_floating_point_v<T>) {
191+ using CppT = __ESIMD_DNS::element_type_traits<T>::EnclosingCppT;
192+ auto Result =
193+ __ESIMD_DNS::convert_vector<T, CppT, SZ>(__spirv_ocl_fmax<CppT, SZ>(
194+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src0.data ()),
195+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src1.data ())));
189196 if constexpr (is_sat)
190197 Result = __esimd_sat<T, T, SZ>(Result);
191198 return simd<T, SZ>(Result);
@@ -269,8 +276,12 @@ template <typename T, int SZ, class Sat = saturation_off_tag>
269276__ESIMD_API simd<T, SZ>(min)(simd<T, SZ> src0, simd<T, SZ> src1, Sat sat = {}) {
270277 constexpr bool is_sat = std::is_same_v<Sat, saturation_on_tag>;
271278
272- if constexpr (std::is_floating_point<T>::value) {
273- auto Result = __spirv_ocl_fmin<T, SZ>(src0.data (), src1.data ());
279+ if constexpr (detail::is_generic_floating_point_v<T>) {
280+ using CppT = __ESIMD_DNS::element_type_traits<T>::EnclosingCppT;
281+ auto Result =
282+ __ESIMD_DNS::convert_vector<T, CppT, SZ>(__spirv_ocl_fmin<CppT, SZ>(
283+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src0.data ()),
284+ __ESIMD_DNS::convert_vector<CppT, T, SZ>(src1.data ())));
274285 if constexpr (is_sat)
275286 Result = __esimd_sat<T, T, SZ>(Result);
276287 return simd<T, SZ>(Result);
@@ -1465,8 +1476,12 @@ template <typename T0, typename T1, int SZ> struct esimd_apply_prod {
14651476template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_max {
14661477 template <typename ... T>
14671478 simd<T0, SZ> operator ()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
1468- if constexpr (std::is_floating_point<T1>::value) {
1469- return __spirv_ocl_fmax<T1, SZ>(v1.data (), v2.data ());
1479+ if constexpr (detail::is_generic_floating_point_v<T1>) {
1480+ using CppT = __ESIMD_DNS::element_type_traits<T1>::EnclosingCppT;
1481+ return __ESIMD_DNS::convert_vector<T1, CppT, SZ>(
1482+ __spirv_ocl_fmax<CppT, SZ>(
1483+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v1.data ()),
1484+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v2.data ())));
14701485 } else if constexpr (std::is_unsigned<T1>::value) {
14711486 return __esimd_umax<T1, SZ>(v1.data (), v2.data ());
14721487 } else {
@@ -1478,8 +1493,13 @@ template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_max {
14781493template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_min {
14791494 template <typename ... T>
14801495 simd<T0, SZ> operator ()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
1481- if constexpr (std::is_floating_point<T1>::value) {
1482- return __spirv_ocl_fmin<T1, SZ>(v1.data (), v2.data ());
1496+
1497+ if constexpr (detail::is_generic_floating_point_v<T1>) {
1498+ using CppT = __ESIMD_DNS::element_type_traits<T1>::EnclosingCppT;
1499+ return __ESIMD_DNS::convert_vector<T1, CppT, SZ>(
1500+ __spirv_ocl_fmin<CppT, SZ>(
1501+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v1.data ()),
1502+ __ESIMD_DNS::convert_vector<CppT, T1, SZ>(v2.data ())));
14831503 } else if constexpr (std::is_unsigned<T1>::value) {
14841504 return __esimd_umin<T1, SZ>(v1.data (), v2.data ());
14851505 } else {
0 commit comments