Skip to content

Commit 50ea812

Browse files
committed
[builtins] Use __builtin_clzll for 64-bit types
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 0284b4b commit 50ea812

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

compiler-rt/lib/builtins/fp_extend.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,7 @@ static const int srcSigFracBits = 52;
3838
static const int srcExpBits = 11;
3939

4040
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
41+
return __builtin_clzll(a);
4942
}
5043
#define src_rep_t_clz src_rep_t_clz_impl
5144

compiler-rt/lib/builtins/fp_lib.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,8 @@ 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
61+
static inline int rep_clz(rep_t a) {
62+
return __builtin_clzll(a);
7063
}
7164

7265
#define loWord(a) (a & 0xffffffffU)

0 commit comments

Comments
 (0)