-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[HIP] Fix return type in __clang_hip_cmath.h #139697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-x86 Author: Juan Manuel Martinez Caamaño (jmmartinez) ChangesBefore, some functions like I've stumbled upon this bug while trying to adapt
Full diff: https://github.com/llvm/llvm-project/pull/139697.diff 1 Files Affected:
diff --git a/clang/lib/Headers/__clang_hip_cmath.h b/clang/lib/Headers/__clang_hip_cmath.h
index 7d982ad9af7ee..8039d0e12d7c9 100644
--- a/clang/lib/Headers/__clang_hip_cmath.h
+++ b/clang/lib/Headers/__clang_hip_cmath.h
@@ -464,12 +464,13 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
#if __cplusplus >= 201103L
#define __HIP_OVERLOAD2(__retty, __fn) \
template <typename __T1, typename __T2> \
- __DEVICE__ __CONSTEXPR__ typename __hip_enable_if< \
- __hip::is_arithmetic<__T1>::value && __hip::is_arithmetic<__T2>::value, \
- typename __hip::__promote<__T1, __T2>::type>::type \
- __fn(__T1 __x, __T2 __y) { \
- typedef typename __hip::__promote<__T1, __T2>::type __result_type; \
- return __fn((__result_type)__x, (__result_type)__y); \
+ __DEVICE__ __CONSTEXPR__ \
+ typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && \
+ __hip::is_arithmetic<__T2>::value, \
+ __retty>::type \
+ __fn(__T1 __x, __T2 __y) { \
+ typedef typename __hip::__promote<__T1, __T2>::type __arg_type; \
+ return __fn((__arg_type)__x, (__arg_type)__y); \
}
#else
#define __HIP_OVERLOAD2(__retty, __fn) \
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs header test
Added tests and created a separate PR to commit the tests before the fix in #139891 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks
Before, some functions like std::isgreater(double, doulbe) would return a double instead of a bool.
…th.h (#139891) Tests related to llvm/llvm-project#139697
Before, some functions like
isgreater(float, double)
would return adouble
instead of abool
.I've stumbled upon this bug while trying to adapt
External/CUDA/cmath.cu
to HIP.