Skip to content

Commit 735974e

Browse files
authored
[builtins] Use __builtin_clzll for 64-bit types (llvm#99874)
This addresses the issue with `__LP64__` not being defined for targets with 32-bit pointers but 64-bit longs, resulting in worse codegen.
1 parent 0eb719f commit 735974e

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

compiler-rt/lib/builtins/fp_extend.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ static const int srcSigFracBits = 52;
3737
// srcBits - srcSigFracBits - 1
3838
static const int srcExpBits = 11;
3939

40-
static inline int src_rep_t_clz_impl(src_rep_t a) {
41-
#if defined __LP64__
42-
return __builtin_clzl(a);
43-
#else
44-
if (a & REP_C(0xffffffff00000000))
45-
return clzsi(a >> 32);
46-
else
47-
return 32 + clzsi(a & REP_C(0xffffffff));
48-
#endif
49-
}
40+
static inline int src_rep_t_clz_impl(src_rep_t a) { return __builtin_clzll(a); }
5041
#define src_rep_t_clz src_rep_t_clz_impl
5142

5243
#elif defined SRC_80

compiler-rt/lib/builtins/fp_lib.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,7 @@ typedef double fp_t;
5858
#define REP_C UINT64_C
5959
#define significandBits 52
6060

61-
static __inline int rep_clz(rep_t a) {
62-
#if defined __LP64__
63-
return __builtin_clzl(a);
64-
#else
65-
if (a & REP_C(0xffffffff00000000))
66-
return clzsi(a >> 32);
67-
else
68-
return 32 + clzsi(a & REP_C(0xffffffff));
69-
#endif
70-
}
61+
static inline int rep_clz(rep_t a) { return __builtin_clzll(a); }
7162

7263
#define loWord(a) (a & 0xffffffffU)
7364
#define hiWord(a) (a >> 32)

0 commit comments

Comments
 (0)