[xcc] minor performance tweaks
[riscv-isa-sim.git] / softfloat / i32_to_f64.c
1
2 #include <stdbool.h>
3 #include <stdint.h>
4 #include "platform.h"
5 #include "primitives.h"
6 #include "internals.h"
7 #include "softfloat.h"
8
9 float64_t i32_to_f64( int_fast32_t a )
10 {
11 uint_fast64_t uiZ;
12 bool sign;
13 uint_fast32_t absA;
14 int shiftCount;
15 union ui64_f64 uZ;
16
17 if ( ! a ) {
18 uiZ = 0;
19 } else {
20 sign = ( a < 0 );
21 absA = sign ? - a : a;
22 shiftCount = softfloat_countLeadingZeros32( absA ) + 21;
23 uiZ =
24 packToF64UI(
25 sign, 0x432 - shiftCount, (uint_fast64_t) absA<<shiftCount );
26 }
27 uZ.ui = uiZ;
28 return uZ.f;
29
30 }
31