[compiler-rt] 4bcd258 - [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 30 12:06:40 PST 2022
Author: Anatoly Trosinenko
Date: 2022-01-30T23:04:07+03:00
New Revision: 4bcd2588a9869791e5e2232e0454cc1648a786d4
URL: https://github.com/llvm/llvm-project/commit/4bcd2588a9869791e5e2232e0454cc1648a786d4
DIFF: https://github.com/llvm/llvm-project/commit/4bcd2588a9869791e5e2232e0454cc1648a786d4.diff
LOG: [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z
`__builtin_c[tl]z` accepts `unsigned int` argument that is not always the
same as uint32_t. For example, `unsigned int` is uint16_t on MSP430.
Reviewed By: aykevl
Differential Revision: https://reviews.llvm.org/D86547
Added:
Modified:
compiler-rt/lib/builtins/floatsisf.c
compiler-rt/lib/builtins/floatsitf.c
compiler-rt/lib/builtins/floatunsisf.c
compiler-rt/lib/builtins/floatunsitf.c
compiler-rt/lib/builtins/fp_extend.h
compiler-rt/lib/builtins/udivmoddi4.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/floatsisf.c b/compiler-rt/lib/builtins/floatsisf.c
index 5f3ee99146bc..c01f81e41e8e 100644
--- a/compiler-rt/lib/builtins/floatsisf.c
+++ b/compiler-rt/lib/builtins/floatsisf.c
@@ -33,7 +33,7 @@ COMPILER_RT_ABI fp_t __floatsisf(si_int a) {
}
// Exponent of (fp_t)a is the width of abs(a).
- const int exponent = (aWidth - 1) - __builtin_clz(a);
+ const int exponent = (aWidth - 1) - clzsi(a);
rep_t result;
// Shift a into the significand field, rounding if it is a right-shift
diff --git a/compiler-rt/lib/builtins/floatsitf.c b/compiler-rt/lib/builtins/floatsitf.c
index e6e392a50646..80a4ef08fb0e 100644
--- a/compiler-rt/lib/builtins/floatsitf.c
+++ b/compiler-rt/lib/builtins/floatsitf.c
@@ -33,7 +33,7 @@ COMPILER_RT_ABI fp_t __floatsitf(si_int a) {
}
// Exponent of (fp_t)a is the width of abs(a).
- const int exponent = (aWidth - 1) - __builtin_clz(aAbs);
+ const int exponent = (aWidth - 1) - clzsi(aAbs);
rep_t result;
// Shift a into the significand field and clear the implicit bit.
diff --git a/compiler-rt/lib/builtins/floatunsisf.c b/compiler-rt/lib/builtins/floatunsisf.c
index fb9bd6f082b6..ec062b5943e9 100644
--- a/compiler-rt/lib/builtins/floatunsisf.c
+++ b/compiler-rt/lib/builtins/floatunsisf.c
@@ -26,7 +26,7 @@ COMPILER_RT_ABI fp_t __floatunsisf(su_int a) {
return fromRep(0);
// Exponent of (fp_t)a is the width of abs(a).
- const int exponent = (aWidth - 1) - __builtin_clz(a);
+ const int exponent = (aWidth - 1) - clzsi(a);
rep_t result;
// Shift a into the significand field, rounding if it is a right-shift
diff --git a/compiler-rt/lib/builtins/floatunsitf.c b/compiler-rt/lib/builtins/floatunsitf.c
index 765eaccd687a..7ba1fb6000dc 100644
--- a/compiler-rt/lib/builtins/floatunsitf.c
+++ b/compiler-rt/lib/builtins/floatunsitf.c
@@ -25,7 +25,7 @@ COMPILER_RT_ABI fp_t __floatunsitf(su_int a) {
return fromRep(0);
// Exponent of (fp_t)a is the width of abs(a).
- const int exponent = (aWidth - 1) - __builtin_clz(a);
+ const int exponent = (aWidth - 1) - clzsi(a);
rep_t result;
// Shift a into the significand field and clear the implicit bit.
diff --git a/compiler-rt/lib/builtins/fp_extend.h b/compiler-rt/lib/builtins/fp_extend.h
index aad4436730dd..eee4722bf90e 100644
--- a/compiler-rt/lib/builtins/fp_extend.h
+++ b/compiler-rt/lib/builtins/fp_extend.h
@@ -33,9 +33,9 @@ static __inline int src_rep_t_clz(src_rep_t a) {
return __builtin_clzl(a);
#else
if (a & REP_C(0xffffffff00000000))
- return __builtin_clz(a >> 32);
+ return clzsi(a >> 32);
else
- return 32 + __builtin_clz(a & REP_C(0xffffffff));
+ return 32 + clzsi(a & REP_C(0xffffffff));
#endif
}
diff --git a/compiler-rt/lib/builtins/udivmoddi4.c b/compiler-rt/lib/builtins/udivmoddi4.c
index ca17b36ce585..123e5fb05f8c 100644
--- a/compiler-rt/lib/builtins/udivmoddi4.c
+++ b/compiler-rt/lib/builtins/udivmoddi4.c
@@ -82,7 +82,7 @@ COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int *rem) {
r.s.high = n.s.high & (d.s.high - 1);
*rem = r.all;
}
- return n.s.high >> __builtin_ctz(d.s.high);
+ return n.s.high >> ctzsi(d.s.high);
}
// K K
// ---
@@ -112,7 +112,7 @@ COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int *rem) {
*rem = n.s.low & (d.s.low - 1);
if (d.s.low == 1)
return n.all;
- sr = __builtin_ctz(d.s.low);
+ sr = ctzsi(d.s.low);
q.s.high = n.s.high >> sr;
q.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
return q.all;
More information about the llvm-commits
mailing list