Commit e13dd54f by Joseph Myers Committed by Joseph Myers

fp-bit.h (LSHIFT): Take shift count parameter.

	* config/fp-bit.h (LSHIFT): Take shift count parameter.
	* config/fp-bit.c (_fpadd_parts): Shift in one go instead of one
	bit at a time.

From-SVN: r107602
parent e97f2058
2005-11-28 Joseph S. Myers <joseph@codesourcery.com>
* config/fp-bit.h (LSHIFT): Take shift count parameter.
* config/fp-bit.c (_fpadd_parts): Shift in one go instead of one
bit at a time.
2005-11-28 Bernd Schmidt <bernd.schmidt@analog.com> 2005-11-28 Bernd Schmidt <bernd.schmidt@analog.com>
* config/bfin/bfin.c (bfin_secondary_reload): Renamed from * config/bfin/bfin.c (bfin_secondary_reload): Renamed from
......
...@@ -649,6 +649,7 @@ _fpadd_parts (fp_number_type * a, ...@@ -649,6 +649,7 @@ _fpadd_parts (fp_number_type * a,
they're the same */ they're the same */
{ {
int diff; int diff;
int sdiff;
a_normal_exp = a->normal_exp; a_normal_exp = a->normal_exp;
b_normal_exp = b->normal_exp; b_normal_exp = b->normal_exp;
...@@ -656,21 +657,21 @@ _fpadd_parts (fp_number_type * a, ...@@ -656,21 +657,21 @@ _fpadd_parts (fp_number_type * a,
b_fraction = b->fraction.ll; b_fraction = b->fraction.ll;
diff = a_normal_exp - b_normal_exp; diff = a_normal_exp - b_normal_exp;
sdiff = diff;
if (diff < 0) if (diff < 0)
diff = -diff; diff = -diff;
if (diff < FRAC_NBITS) if (diff < FRAC_NBITS)
{ {
/* ??? This does shifts one bit at a time. Optimize. */ if (sdiff > 0)
while (a_normal_exp > b_normal_exp)
{ {
b_normal_exp++; b_normal_exp += diff;
LSHIFT (b_fraction); LSHIFT (b_fraction, diff);
} }
while (b_normal_exp > a_normal_exp) else if (sdiff < 0)
{ {
a_normal_exp++; a_normal_exp += diff;
LSHIFT (a_fraction); LSHIFT (a_fraction, diff);
} }
} }
else else
...@@ -731,7 +732,7 @@ _fpadd_parts (fp_number_type * a, ...@@ -731,7 +732,7 @@ _fpadd_parts (fp_number_type * a,
if (tmp->fraction.ll >= IMPLICIT_2) if (tmp->fraction.ll >= IMPLICIT_2)
{ {
LSHIFT (tmp->fraction.ll); LSHIFT (tmp->fraction.ll, 1);
tmp->normal_exp++; tmp->normal_exp++;
} }
return tmp; return tmp;
......
...@@ -318,7 +318,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); ...@@ -318,7 +318,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
#endif #endif
/* Preserve the sticky-bit when shifting fractions to the right. */ /* Preserve the sticky-bit when shifting fractions to the right. */
#define LSHIFT(a) { a = (a & 1) | (a >> 1); } #define LSHIFT(a, s) { a = (a >> s) | !!(a & (((fractype) 1 << s) - 1)); }
/* numeric parameters */ /* numeric parameters */
/* F_D_BITOFF is the number of bits offset between the MSB of the mantissa /* F_D_BITOFF is the number of bits offset between the MSB of the mantissa
......
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