Author: Matt Arsenault Date: 2023-08-15T17:40:19-04:00 New Revision: 43f314f5e6cebe02ff63d5197c8e5c25204b20d2
URL: https://github.com/llvm/llvm-project/commit/43f314f5e6cebe02ff63d5197c8e5c25204b20d2 DIFF: https://github.com/llvm/llvm-project/commit/43f314f5e6cebe02ff63d5197c8e5c25204b20d2.diff LOG: clang/HIP: Use abs builtins instead of implementing them InstCombine already put these back together so there's no visible change in the -O1 test for the header. Added: Modified: clang/lib/Headers/__clang_hip_math.h Removed: ################################################################################ diff --git a/clang/lib/Headers/__clang_hip_math.h b/clang/lib/Headers/__clang_hip_math.h index 8721167304a665..120961967d840f 100644 --- a/clang/lib/Headers/__clang_hip_math.h +++ b/clang/lib/Headers/__clang_hip_math.h @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits