Skip to content

Commit

Permalink
clang/HIP: Use abs builtins instead of implementing them
Browse files Browse the repository at this point in the history
InstCombine already put these back together so there's no visible
change in the -O1 test for the header.
  • Loading branch information
arsenm committed Aug 15, 2023
1 parent a68b87d commit 43f314f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions clang/lib/Headers/__clang_hip_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,18 +315,15 @@ float __tanf(float __x) {
#if defined(__cplusplus)
__DEVICE__
int abs(int __x) {
int __sgn = __x >> (sizeof(int) * CHAR_BIT - 1);
return (__x ^ __sgn) - __sgn;
return __builtin_abs(__x);
}
__DEVICE__
long labs(long __x) {
long __sgn = __x >> (sizeof(long) * CHAR_BIT - 1);
return (__x ^ __sgn) - __sgn;
return __builtin_labs(__x);
}
__DEVICE__
long long llabs(long long __x) {
long long __sgn = __x >> (sizeof(long long) * CHAR_BIT - 1);
return (__x ^ __sgn) - __sgn;
return __builtin_llabs(__x);
}
#endif

Expand Down

0 comments on commit 43f314f

Please sign in to comment.