Commit b982024e by Kaveh R. Ghazi Committed by Kaveh Ghazi

libgcc2.c (__negdi2, [...]): Const-ify and/or initialize automatic variables at declaration.

	* libgcc2.c (__negdi2, __addvsi3, __addvdi3, __subvsi3, __subvdi3,
	__mulvsi3, __negvsi2, __negvdi2, __mulvdi3, __lshrdi3, __ashldi3,
	__ashrdi3, __ffsDI2, __muldi3, __clzDI2, __ctzDI2, __parityDI2,
	__udivmoddi4, __divdi3, __moddi3, __cmpdi2, __ucmpdi2,
	__fixunstfDI, __fixunsxfDI, __fixunsdfDI, __fixunssfDI,
	__floatdixf, __floatditf, __floatdidf, __floatdisf, __gcc_bcmp):
	Const-ify and/or initialize automatic variables at declaration.

From-SVN: r73573
parent ef1f2e12
2003-11-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* libgcc2.c (__negdi2, __addvsi3, __addvdi3, __subvsi3, __subvdi3,
__mulvsi3, __negvsi2, __negvdi2, __mulvdi3, __lshrdi3, __ashldi3,
__ashrdi3, __ffsDI2, __muldi3, __clzDI2, __ctzDI2, __parityDI2,
__udivmoddi4, __divdi3, __moddi3, __cmpdi2, __ucmpdi2,
__fixunstfDI, __fixunsxfDI, __fixunsdfDI, __fixunssfDI,
__floatdixf, __floatditf, __floatdidf, __floatdisf, __gcc_bcmp):
Const-ify and/or initialize automatic variables at declaration.
2003-11-13 Kazu Hirata <kazu@cs.umass.edu> 2003-11-13 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/lib1funcs.asm (divmodsi4): Replace all the uses * config/h8300/lib1funcs.asm (divmodsi4): Replace all the uses
......
...@@ -63,13 +63,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -63,13 +63,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
DWtype DWtype
__negdi2 (DWtype u) __negdi2 (DWtype u)
{ {
DWunion w; const DWunion uu = {.ll = u};
DWunion uu; const DWunion w = { {.low = -uu.s.low,
.high = -uu.s.high - ((UWtype) -uu.s.low > 0) } };
uu.ll = u;
w.s.low = -uu.s.low;
w.s.high = -uu.s.high - ((UWtype) w.s.low > 0);
return w.ll; return w.ll;
} }
...@@ -79,9 +75,7 @@ __negdi2 (DWtype u) ...@@ -79,9 +75,7 @@ __negdi2 (DWtype u)
Wtype Wtype
__addvsi3 (Wtype a, Wtype b) __addvsi3 (Wtype a, Wtype b)
{ {
Wtype w; const Wtype w = a + b;
w = a + b;
if (b >= 0 ? w < a : w > a) if (b >= 0 ? w < a : w > a)
abort (); abort ();
...@@ -94,9 +88,7 @@ __addvsi3 (Wtype a, Wtype b) ...@@ -94,9 +88,7 @@ __addvsi3 (Wtype a, Wtype b)
DWtype DWtype
__addvdi3 (DWtype a, DWtype b) __addvdi3 (DWtype a, DWtype b)
{ {
DWtype w; const DWtype w = a + b;
w = a + b;
if (b >= 0 ? w < a : w > a) if (b >= 0 ? w < a : w > a)
abort (); abort ();
...@@ -109,9 +101,7 @@ __addvdi3 (DWtype a, DWtype b) ...@@ -109,9 +101,7 @@ __addvdi3 (DWtype a, DWtype b)
Wtype Wtype
__subvsi3 (Wtype a, Wtype b) __subvsi3 (Wtype a, Wtype b)
{ {
DWtype w; const DWtype w = a - b;
w = a - b;
if (b >= 0 ? w > a : w < a) if (b >= 0 ? w > a : w < a)
abort (); abort ();
...@@ -124,9 +114,7 @@ __subvsi3 (Wtype a, Wtype b) ...@@ -124,9 +114,7 @@ __subvsi3 (Wtype a, Wtype b)
DWtype DWtype
__subvdi3 (DWtype a, DWtype b) __subvdi3 (DWtype a, DWtype b)
{ {
DWtype w; const DWtype w = a - b;
w = a - b;
if (b >= 0 ? w > a : w < a) if (b >= 0 ? w > a : w < a)
abort (); abort ();
...@@ -140,9 +128,7 @@ __subvdi3 (DWtype a, DWtype b) ...@@ -140,9 +128,7 @@ __subvdi3 (DWtype a, DWtype b)
Wtype Wtype
__mulvsi3 (Wtype a, Wtype b) __mulvsi3 (Wtype a, Wtype b)
{ {
DWtype w; const DWtype w = (DWtype) a * (DWtype) b;
w = (DWtype) a * (DWtype) b;
if (((a >= 0) == (b >= 0)) if (((a >= 0) == (b >= 0))
? (UDWtype) w > (UDWtype) (((DWtype) 1 << (WORD_SIZE - 1)) - 1) ? (UDWtype) w > (UDWtype) (((DWtype) 1 << (WORD_SIZE - 1)) - 1)
...@@ -157,9 +143,7 @@ __mulvsi3 (Wtype a, Wtype b) ...@@ -157,9 +143,7 @@ __mulvsi3 (Wtype a, Wtype b)
Wtype Wtype
__negvsi2 (Wtype a) __negvsi2 (Wtype a)
{ {
Wtype w; const Wtype w = -a;
w = -a;
if (a >= 0 ? w > 0 : w < 0) if (a >= 0 ? w > 0 : w < 0)
abort (); abort ();
...@@ -172,9 +156,7 @@ __negvsi2 (Wtype a) ...@@ -172,9 +156,7 @@ __negvsi2 (Wtype a)
DWtype DWtype
__negvdi2 (DWtype a) __negvdi2 (DWtype a)
{ {
DWtype w; const DWtype w = -a;
w = -a;
if (a >= 0 ? w > 0 : w < 0) if (a >= 0 ? w > 0 : w < 0)
abort (); abort ();
...@@ -230,10 +212,8 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -230,10 +212,8 @@ __mulvdi3 (DWtype u, DWtype v)
{ {
/* The unchecked multiplication needs 3 Wtype x Wtype multiplications, /* The unchecked multiplication needs 3 Wtype x Wtype multiplications,
but the checked multiplication needs only two. */ but the checked multiplication needs only two. */
DWunion uu, vv; const DWunion uu = {.ll = u};
const DWunion vv = {.ll = v};
uu.ll = u;
vv.ll = v;
if (__builtin_expect (uu.s.high == uu.s.low >> (WORD_SIZE - 1), 1)) if (__builtin_expect (uu.s.high == uu.s.low >> (WORD_SIZE - 1), 1))
{ {
...@@ -247,10 +227,11 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -247,10 +227,11 @@ __mulvdi3 (DWtype u, DWtype v)
else else
{ {
/* Two multiplications. */ /* Two multiplications. */
DWunion w0, w1; DWunion w0 = {.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low};
DWunion w1 = {.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.high};
w0.ll = (UDWtype) (UWtype) uu.s.low * (UDWtype) (UWtype) vv.s.low;
w1.ll = (UDWtype) (UWtype) uu.s.low * (UDWtype) (UWtype) vv.s.high;
if (vv.s.high < 0) if (vv.s.high < 0)
w1.s.high -= uu.s.low; w1.s.high -= uu.s.low;
if (uu.s.low < 0) if (uu.s.low < 0)
...@@ -269,10 +250,11 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -269,10 +250,11 @@ __mulvdi3 (DWtype u, DWtype v)
{ {
/* v fits into a single Wtype. */ /* v fits into a single Wtype. */
/* Two multiplications. */ /* Two multiplications. */
DWunion w0, w1; DWunion w0 = {.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low};
DWunion w1 = {.ll = (UDWtype) (UWtype) uu.s.high
* (UDWtype) (UWtype) vv.s.low};
w0.ll = (UDWtype) (UWtype) uu.s.low * (UDWtype) (UWtype) vv.s.low;
w1.ll = (UDWtype) (UWtype) uu.s.high * (UDWtype) (UWtype) vv.s.low;
if (uu.s.high < 0) if (uu.s.high < 0)
w1.s.high -= vv.s.low; w1.s.high -= vv.s.low;
if (vv.s.low < 0) if (vv.s.low < 0)
...@@ -293,10 +275,8 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -293,10 +275,8 @@ __mulvdi3 (DWtype u, DWtype v)
{ {
if (uu.s.high == 0 && vv.s.high == 0) if (uu.s.high == 0 && vv.s.high == 0)
{ {
DWtype w; const DWtype w = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low;
w = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low;
if (__builtin_expect (w >= 0, 1)) if (__builtin_expect (w >= 0, 1))
return w; return w;
} }
...@@ -305,10 +285,9 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -305,10 +285,9 @@ __mulvdi3 (DWtype u, DWtype v)
{ {
if (uu.s.high == 0 && vv.s.high == (Wtype) -1) if (uu.s.high == 0 && vv.s.high == (Wtype) -1)
{ {
DWunion ww; DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low};
ww.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low;
ww.s.high -= uu.s.low; ww.s.high -= uu.s.low;
if (__builtin_expect (ww.s.high < 0, 1)) if (__builtin_expect (ww.s.high < 0, 1))
return ww.ll; return ww.ll;
...@@ -321,10 +300,9 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -321,10 +300,9 @@ __mulvdi3 (DWtype u, DWtype v)
{ {
if (uu.s.high == (Wtype) -1 && vv.s.high == 0) if (uu.s.high == (Wtype) -1 && vv.s.high == 0)
{ {
DWunion ww; DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low};
ww.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low;
ww.s.high -= vv.s.low; ww.s.high -= vv.s.low;
if (__builtin_expect (ww.s.high < 0, 1)) if (__builtin_expect (ww.s.high < 0, 1))
return ww.ll; return ww.ll;
...@@ -334,10 +312,9 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -334,10 +312,9 @@ __mulvdi3 (DWtype u, DWtype v)
{ {
if (uu.s.high == (Wtype) -1 && vv.s.high == (Wtype) - 1) if (uu.s.high == (Wtype) -1 && vv.s.high == (Wtype) - 1)
{ {
DWunion ww; DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low};
ww.ll = (UDWtype) (UWtype) uu.s.low
* (UDWtype) (UWtype) vv.s.low;
ww.s.high -= uu.s.low; ww.s.high -= uu.s.low;
ww.s.high -= vv.s.low; ww.s.high -= vv.s.low;
if (__builtin_expect (ww.s.high >= 0, 1)) if (__builtin_expect (ww.s.high >= 0, 1))
...@@ -360,16 +337,13 @@ __mulvdi3 (DWtype u, DWtype v) ...@@ -360,16 +337,13 @@ __mulvdi3 (DWtype u, DWtype v)
DWtype DWtype
__lshrdi3 (DWtype u, word_type b) __lshrdi3 (DWtype u, word_type b)
{ {
DWunion w;
word_type bm;
DWunion uu;
if (b == 0) if (b == 0)
return u; return u;
uu.ll = u; const DWunion uu = {.ll = u};
const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
DWunion w;
bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
if (bm <= 0) if (bm <= 0)
{ {
w.s.high = 0; w.s.high = 0;
...@@ -377,7 +351,7 @@ __lshrdi3 (DWtype u, word_type b) ...@@ -377,7 +351,7 @@ __lshrdi3 (DWtype u, word_type b)
} }
else else
{ {
UWtype carries = (UWtype) uu.s.high << bm; const UWtype carries = (UWtype) uu.s.high << bm;
w.s.high = (UWtype) uu.s.high >> b; w.s.high = (UWtype) uu.s.high >> b;
w.s.low = ((UWtype) uu.s.low >> b) | carries; w.s.low = ((UWtype) uu.s.low >> b) | carries;
...@@ -391,16 +365,13 @@ __lshrdi3 (DWtype u, word_type b) ...@@ -391,16 +365,13 @@ __lshrdi3 (DWtype u, word_type b)
DWtype DWtype
__ashldi3 (DWtype u, word_type b) __ashldi3 (DWtype u, word_type b)
{ {
DWunion w;
word_type bm;
DWunion uu;
if (b == 0) if (b == 0)
return u; return u;
uu.ll = u; const DWunion uu = {.ll = u};
const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
DWunion w;
bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
if (bm <= 0) if (bm <= 0)
{ {
w.s.low = 0; w.s.low = 0;
...@@ -408,7 +379,7 @@ __ashldi3 (DWtype u, word_type b) ...@@ -408,7 +379,7 @@ __ashldi3 (DWtype u, word_type b)
} }
else else
{ {
UWtype carries = (UWtype) uu.s.low >> bm; const UWtype carries = (UWtype) uu.s.low >> bm;
w.s.low = (UWtype) uu.s.low << b; w.s.low = (UWtype) uu.s.low << b;
w.s.high = ((UWtype) uu.s.high << b) | carries; w.s.high = ((UWtype) uu.s.high << b) | carries;
...@@ -422,16 +393,13 @@ __ashldi3 (DWtype u, word_type b) ...@@ -422,16 +393,13 @@ __ashldi3 (DWtype u, word_type b)
DWtype DWtype
__ashrdi3 (DWtype u, word_type b) __ashrdi3 (DWtype u, word_type b)
{ {
DWunion w;
word_type bm;
DWunion uu;
if (b == 0) if (b == 0)
return u; return u;
uu.ll = u; const DWunion uu = {.ll = u};
const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
DWunion w;
bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
if (bm <= 0) if (bm <= 0)
{ {
/* w.s.high = 1..1 or 0..0 */ /* w.s.high = 1..1 or 0..0 */
...@@ -440,7 +408,7 @@ __ashrdi3 (DWtype u, word_type b) ...@@ -440,7 +408,7 @@ __ashrdi3 (DWtype u, word_type b)
} }
else else
{ {
UWtype carries = (UWtype) uu.s.high << bm; const UWtype carries = (UWtype) uu.s.high << bm;
w.s.high = uu.s.high >> b; w.s.high = uu.s.high >> b;
w.s.low = ((UWtype) uu.s.low >> b) | carries; w.s.low = ((UWtype) uu.s.low >> b) | carries;
...@@ -472,10 +440,9 @@ extern int __ffsDI2 (DWtype u); ...@@ -472,10 +440,9 @@ extern int __ffsDI2 (DWtype u);
int int
__ffsDI2 (DWtype u) __ffsDI2 (DWtype u)
{ {
DWunion uu; const DWunion uu = {.ll = u};
UWtype word, count, add; UWtype word, count, add;
uu.ll = u;
if (uu.s.low != 0) if (uu.s.low != 0)
word = uu.s.low, add = 0; word = uu.s.low, add = 0;
else if (uu.s.high != 0) else if (uu.s.high != 0)
...@@ -492,13 +459,10 @@ __ffsDI2 (DWtype u) ...@@ -492,13 +459,10 @@ __ffsDI2 (DWtype u)
DWtype DWtype
__muldi3 (DWtype u, DWtype v) __muldi3 (DWtype u, DWtype v)
{ {
DWunion w; const DWunion uu = {.ll = u};
DWunion uu, vv; const DWunion vv = {.ll = v};
DWunion w = {.ll = __umulsidi3 (uu.s.low, vv.s.low)};
uu.ll = u,
vv.ll = v;
w.ll = __umulsidi3 (uu.s.low, vv.s.low);
w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high
+ (UWtype) uu.s.high * (UWtype) vv.s.low); + (UWtype) uu.s.high * (UWtype) vv.s.low);
...@@ -667,11 +631,10 @@ extern int __clzDI2 (UDWtype x); ...@@ -667,11 +631,10 @@ extern int __clzDI2 (UDWtype x);
int int
__clzDI2 (UDWtype x) __clzDI2 (UDWtype x)
{ {
DWunion uu; const DWunion uu = {.ll = x};
UWtype word; UWtype word;
Wtype ret, add; Wtype ret, add;
uu.ll = x;
if (uu.s.high) if (uu.s.high)
word = uu.s.high, add = 0; word = uu.s.high, add = 0;
else else
...@@ -702,11 +665,10 @@ extern int __ctzDI2 (UDWtype x); ...@@ -702,11 +665,10 @@ extern int __ctzDI2 (UDWtype x);
int int
__ctzDI2 (UDWtype x) __ctzDI2 (UDWtype x)
{ {
DWunion uu; const DWunion uu = {.ll = x};
UWtype word; UWtype word;
Wtype ret, add; Wtype ret, add;
uu.ll = x;
if (uu.s.low) if (uu.s.low)
word = uu.s.low, add = 0; word = uu.s.low, add = 0;
else else
...@@ -794,11 +756,8 @@ extern int __parityDI2 (UDWtype x); ...@@ -794,11 +756,8 @@ extern int __parityDI2 (UDWtype x);
int int
__parityDI2 (UDWtype x) __parityDI2 (UDWtype x)
{ {
DWunion uu; const DWunion uu = {.ll = x};
UWtype nx; UWtype nx = uu.s.low ^ uu.s.high;
uu.ll = x;
nx = uu.s.low ^ uu.s.high;
#if W_TYPE_SIZE > 64 #if W_TYPE_SIZE > 64
# error "fill out the table" # error "fill out the table"
...@@ -825,16 +784,13 @@ static inline __attribute__ ((__always_inline__)) ...@@ -825,16 +784,13 @@ static inline __attribute__ ((__always_inline__))
UDWtype UDWtype
__udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
{ {
DWunion ww; const DWunion nn = {.ll = n};
DWunion nn, dd; const DWunion dd = {.ll = d};
DWunion rr; DWunion rr;
UWtype d0, d1, n0, n1, n2; UWtype d0, d1, n0, n1, n2;
UWtype q0, q1; UWtype q0, q1;
UWtype b, bm; UWtype b, bm;
nn.ll = n;
dd.ll = d;
d0 = dd.s.low; d0 = dd.s.low;
d1 = dd.s.high; d1 = dd.s.high;
n0 = nn.s.low; n0 = nn.s.low;
...@@ -1034,8 +990,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) ...@@ -1034,8 +990,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
} }
} }
ww.s.low = q0; const DWunion ww = {{.low = q0, .high = q1}};
ww.s.high = q1;
return ww.ll; return ww.ll;
} }
#endif #endif
...@@ -1045,12 +1000,10 @@ DWtype ...@@ -1045,12 +1000,10 @@ DWtype
__divdi3 (DWtype u, DWtype v) __divdi3 (DWtype u, DWtype v)
{ {
word_type c = 0; word_type c = 0;
DWunion uu, vv; DWunion uu = {.ll = u};
DWunion vv = {.ll = v};
DWtype w; DWtype w;
uu.ll = u;
vv.ll = v;
if (uu.s.high < 0) if (uu.s.high < 0)
c = ~c, c = ~c,
uu.ll = -uu.ll; uu.ll = -uu.ll;
...@@ -1071,12 +1024,10 @@ DWtype ...@@ -1071,12 +1024,10 @@ DWtype
__moddi3 (DWtype u, DWtype v) __moddi3 (DWtype u, DWtype v)
{ {
word_type c = 0; word_type c = 0;
DWunion uu, vv; DWunion uu = {.ll = u};
DWunion vv = {.ll = v};
DWtype w; DWtype w;
uu.ll = u;
vv.ll = v;
if (uu.s.high < 0) if (uu.s.high < 0)
c = ~c, c = ~c,
uu.ll = -uu.ll; uu.ll = -uu.ll;
...@@ -1115,9 +1066,8 @@ __udivdi3 (UDWtype n, UDWtype d) ...@@ -1115,9 +1066,8 @@ __udivdi3 (UDWtype n, UDWtype d)
word_type word_type
__cmpdi2 (DWtype a, DWtype b) __cmpdi2 (DWtype a, DWtype b)
{ {
DWunion au, bu; const DWunion au = {.ll = a};
const DWunion bu = {.ll = b};
au.ll = a, bu.ll = b;
if (au.s.high < bu.s.high) if (au.s.high < bu.s.high)
return 0; return 0;
...@@ -1135,9 +1085,8 @@ __cmpdi2 (DWtype a, DWtype b) ...@@ -1135,9 +1085,8 @@ __cmpdi2 (DWtype a, DWtype b)
word_type word_type
__ucmpdi2 (DWtype a, DWtype b) __ucmpdi2 (DWtype a, DWtype b)
{ {
DWunion au, bu; const DWunion au = {.ll = a};
const DWunion bu = {.ll = b};
au.ll = a, bu.ll = b;
if ((UWtype) au.s.high < (UWtype) bu.s.high) if ((UWtype) au.s.high < (UWtype) bu.s.high)
return 0; return 0;
...@@ -1158,17 +1107,14 @@ __ucmpdi2 (DWtype a, DWtype b) ...@@ -1158,17 +1107,14 @@ __ucmpdi2 (DWtype a, DWtype b)
DWtype DWtype
__fixunstfDI (TFtype a) __fixunstfDI (TFtype a)
{ {
TFtype b;
UDWtype v;
if (a < 0) if (a < 0)
return 0; return 0;
/* Compute high word of result, as a flonum. */ /* Compute high word of result, as a flonum. */
b = (a / HIGH_WORD_COEFF); const TFtype b = (a / HIGH_WORD_COEFF);
/* Convert that to fixed (but not to DWtype!), /* Convert that to fixed (but not to DWtype!),
and shift it into the high word. */ and shift it into the high word. */
v = (UWtype) b; UDWtype v = (UWtype) b;
v <<= WORD_SIZE; v <<= WORD_SIZE;
/* Remove high part from the TFtype, leaving the low part as flonum. */ /* Remove high part from the TFtype, leaving the low part as flonum. */
a -= (TFtype)v; a -= (TFtype)v;
...@@ -1200,17 +1146,14 @@ __fixtfdi (TFtype a) ...@@ -1200,17 +1146,14 @@ __fixtfdi (TFtype a)
DWtype DWtype
__fixunsxfDI (XFtype a) __fixunsxfDI (XFtype a)
{ {
XFtype b;
UDWtype v;
if (a < 0) if (a < 0)
return 0; return 0;
/* Compute high word of result, as a flonum. */ /* Compute high word of result, as a flonum. */
b = (a / HIGH_WORD_COEFF); const XFtype b = (a / HIGH_WORD_COEFF);
/* Convert that to fixed (but not to DWtype!), /* Convert that to fixed (but not to DWtype!),
and shift it into the high word. */ and shift it into the high word. */
v = (UWtype) b; UDWtype v = (UWtype) b;
v <<= WORD_SIZE; v <<= WORD_SIZE;
/* Remove high part from the XFtype, leaving the low part as flonum. */ /* Remove high part from the XFtype, leaving the low part as flonum. */
a -= (XFtype)v; a -= (XFtype)v;
...@@ -1242,17 +1185,15 @@ __fixxfdi (XFtype a) ...@@ -1242,17 +1185,15 @@ __fixxfdi (XFtype a)
DWtype DWtype
__fixunsdfDI (DFtype a) __fixunsdfDI (DFtype a)
{ {
UWtype hi, lo;
/* Get high part of result. The division here will just moves the radix /* Get high part of result. The division here will just moves the radix
point and will not cause any rounding. Then the conversion to integral point and will not cause any rounding. Then the conversion to integral
type chops result as desired. */ type chops result as desired. */
hi = a / HIGH_WORD_COEFF; const UWtype hi = a / HIGH_WORD_COEFF;
/* Get low part of result. Convert `hi' to floating type and scale it back, /* Get low part of result. Convert `hi' to floating type and scale it back,
then subtract this from the number being converted. This leaves the low then subtract this from the number being converted. This leaves the low
part. Convert that to integral type. */ part. Convert that to integral type. */
lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF); const UWtype lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF);
/* Assemble result from the two parts. */ /* Assemble result from the two parts. */
return ((UDWtype) hi << WORD_SIZE) | lo; return ((UDWtype) hi << WORD_SIZE) | lo;
...@@ -1279,18 +1220,17 @@ __fixunssfDI (SFtype original_a) ...@@ -1279,18 +1220,17 @@ __fixunssfDI (SFtype original_a)
/* Convert the SFtype to a DFtype, because that is surely not going /* Convert the SFtype to a DFtype, because that is surely not going
to lose any bits. Some day someone else can write a faster version to lose any bits. Some day someone else can write a faster version
that avoids converting to DFtype, and verify it really works right. */ that avoids converting to DFtype, and verify it really works right. */
DFtype a = original_a; const DFtype a = original_a;
UWtype hi, lo;
/* Get high part of result. The division here will just moves the radix /* Get high part of result. The division here will just moves the radix
point and will not cause any rounding. Then the conversion to integral point and will not cause any rounding. Then the conversion to integral
type chops result as desired. */ type chops result as desired. */
hi = a / HIGH_WORD_COEFF; const UWtype hi = a / HIGH_WORD_COEFF;
/* Get low part of result. Convert `hi' to floating type and scale it back, /* Get low part of result. Convert `hi' to floating type and scale it back,
then subtract this from the number being converted. This leaves the low then subtract this from the number being converted. This leaves the low
part. Convert that to integral type. */ part. Convert that to integral type. */
lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF); const UWtype lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF);
/* Assemble result from the two parts. */ /* Assemble result from the two parts. */
return ((UDWtype) hi << WORD_SIZE) | lo; return ((UDWtype) hi << WORD_SIZE) | lo;
...@@ -1315,9 +1255,7 @@ __fixsfdi (SFtype a) ...@@ -1315,9 +1255,7 @@ __fixsfdi (SFtype a)
XFtype XFtype
__floatdixf (DWtype u) __floatdixf (DWtype u)
{ {
XFtype d; XFtype d = (Wtype) (u >> WORD_SIZE);
d = (Wtype) (u >> WORD_SIZE);
d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF;
d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF;
d += (UWtype) (u & (HIGH_WORD_COEFF - 1)); d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
...@@ -1334,9 +1272,7 @@ __floatdixf (DWtype u) ...@@ -1334,9 +1272,7 @@ __floatdixf (DWtype u)
TFtype TFtype
__floatditf (DWtype u) __floatditf (DWtype u)
{ {
TFtype d; TFtype d = (Wtype) (u >> WORD_SIZE);
d = (Wtype) (u >> WORD_SIZE);
d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF;
d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF;
d += (UWtype) (u & (HIGH_WORD_COEFF - 1)); d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
...@@ -1353,9 +1289,7 @@ __floatditf (DWtype u) ...@@ -1353,9 +1289,7 @@ __floatditf (DWtype u)
DFtype DFtype
__floatdidf (DWtype u) __floatdidf (DWtype u)
{ {
DFtype d; DFtype d = (Wtype) (u >> WORD_SIZE);
d = (Wtype) (u >> WORD_SIZE);
d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF;
d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF;
d += (UWtype) (u & (HIGH_WORD_COEFF - 1)); d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
...@@ -1376,11 +1310,6 @@ __floatdidf (DWtype u) ...@@ -1376,11 +1310,6 @@ __floatdidf (DWtype u)
SFtype SFtype
__floatdisf (DWtype u) __floatdisf (DWtype u)
{ {
/* Do the calculation in DFmode
so that we don't lose any of the precision of the high word
while multiplying it. */
DFtype f;
/* Protect against double-rounding error. /* Protect against double-rounding error.
Represent any low-order bits, that might be truncated in DFmode, Represent any low-order bits, that might be truncated in DFmode,
by a bit that won't be lost. The bit can go in anywhere below the by a bit that won't be lost. The bit can go in anywhere below the
...@@ -1401,7 +1330,10 @@ __floatdisf (DWtype u) ...@@ -1401,7 +1330,10 @@ __floatdisf (DWtype u)
} }
} }
} }
f = (Wtype) (u >> WORD_SIZE); /* Do the calculation in DFmode
so that we don't lose any of the precision of the high word
while multiplying it. */
DFtype f = (Wtype) (u >> WORD_SIZE);
f *= HIGH_HALFWORD_COEFF; f *= HIGH_HALFWORD_COEFF;
f *= HIGH_HALFWORD_COEFF; f *= HIGH_HALFWORD_COEFF;
f += (UWtype) (u & (HIGH_WORD_COEFF - 1)); f += (UWtype) (u & (HIGH_WORD_COEFF - 1));
...@@ -1510,7 +1442,7 @@ __gcc_bcmp (const unsigned char *s1, const unsigned char *s2, size_t size) ...@@ -1510,7 +1442,7 @@ __gcc_bcmp (const unsigned char *s1, const unsigned char *s2, size_t size)
{ {
while (size > 0) while (size > 0)
{ {
unsigned char c1 = *s1++, c2 = *s2++; const unsigned char c1 = *s1++, c2 = *s2++;
if (c1 != c2) if (c1 != c2)
return c1 - c2; return c1 - c2;
size--; size--;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment