[xcc] minor performance tweaks
[riscv-isa-sim.git] / softfloat / s_countLeadingZeros64.c
1
2 #include <stdint.h>
3 #include "primitives.h"
4 #include "platform.h"
5
6 int softfloat_countLeadingZeros64( uint64_t a )
7 {
8 int count;
9 uint32_t a32;
10
11 count = 32;
12 a32 = a;
13 if ( UINT64_C( 0x100000000 ) <= a ) {
14 count = 0;
15 a32 = a>>32;
16 }
17 /*------------------------------------------------------------------------
18 | From here, result is current count + count leading zeros of `a32'.
19 *------------------------------------------------------------------------*/
20 if ( a32 < 0x10000 ) {
21 count += 16;
22 a32 <<= 16;
23 }
24 if ( a32 < 0x1000000 ) {
25 count += 8;
26 a32 <<= 8;
27 }
28 count += softfloat_countLeadingZeros8[ a32>>24 ];
29 return count;
30
31 }
32