diff options
Diffstat (limited to 'compiler-rt/lib/builtins/ctzdi2.c')
| -rw-r--r-- | compiler-rt/lib/builtins/ctzdi2.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler-rt/lib/builtins/ctzdi2.c b/compiler-rt/lib/builtins/ctzdi2.c index a25fde15742..3df3e2cf76f 100644 --- a/compiler-rt/lib/builtins/ctzdi2.c +++ b/compiler-rt/lib/builtins/ctzdi2.c @@ -16,8 +16,7 @@ /* Returns: the number of trailing 0-bits */ #if !defined(__clang__) && \ - ((defined(__sparc__) && defined(__arch64__)) || \ - defined(__mips64) || \ + ((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \ (defined(__riscv) && __SIZEOF_POINTER__ >= 8)) /* On 64-bit architectures with neither a native clz instruction nor a native * ctz instruction, gcc resolves __builtin_ctz to __ctzdi2 rather than @@ -28,12 +27,10 @@ extern si_int __ctzsi2(si_int); /* Precondition: a != 0 */ -COMPILER_RT_ABI si_int -__ctzdi2(di_int a) -{ - dwords x; - x.all = a; - const si_int f = -(x.s.low == 0); - return __builtin_ctz((x.s.high & f) | (x.s.low & ~f)) + - (f & ((si_int)(sizeof(si_int) * CHAR_BIT))); +COMPILER_RT_ABI si_int __ctzdi2(di_int a) { + dwords x; + x.all = a; + const si_int f = -(x.s.low == 0); + return __builtin_ctz((x.s.high & f) | (x.s.low & ~f)) + + (f & ((si_int)(sizeof(si_int) * CHAR_BIT))); } |

