]> gcc.gnu.org Git - gcc.git/commitdiff
(div_and_round_double): Don't mix HOST_WIDE_INT * and unsigned
authorRichard Kenner <kenner@gcc.gnu.org>
Tue, 13 Apr 1993 10:07:59 +0000 (06:07 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Tue, 13 Apr 1993 10:07:59 +0000 (06:07 -0400)
HOST_WIDE_INT * parameters; some compilers complain.

From-SVN: r4114

gcc/fold-const.c

index 5e7996096837a6bedcc3180fae48e5faf908d8db..02d40275a7009db88042cdfd0b1d7d9c3d61eebb 100644 (file)
@@ -512,9 +512,9 @@ div_and_round_double (code, uns,
   short den[MAX_SHORTS], quo[MAX_SHORTS];
   register int i, j, work;
   register int carry = 0;
-  unsigned HOST_WIDE_INT lnum = lnum_orig;
+  HOST_WIDE_INT lnum = lnum_orig;
   HOST_WIDE_INT hnum = hnum_orig;
-  unsigned HOST_WIDE_INT lden = lden_orig;
+  HOST_WIDE_INT lden = lden_orig;
   HOST_WIDE_INT hden = hden_orig;
   int overflow = 0;
 
@@ -541,7 +541,8 @@ div_and_round_double (code, uns,
   if (hnum == 0 && hden == 0)
     {                          /* single precision */
       *hquo = *hrem = 0;
-      *lquo = lnum / lden;     /* rounds toward zero since positive args */
+      /* This unsigned division rounds toward zero.  */
+      *lquo = lnum / (unsigned HOST_WIDE_INT) lden;
       goto finish_up;
     }
 
@@ -566,14 +567,14 @@ div_and_round_double (code, uns,
      We also have to require that we don't need more than three bytes
      to hold CARRY.  If we ever did need four bytes to hold it, we
      would lose part of it when computing WORK on the next round.  */
-  if (hden == 0 && ((lden << 8) >> 8) == lden)
+  if (hden == 0 && (((unsigned HOST_WIDE_INT) lden << 8) >> 8) == lden)
     {                          /* simpler algorithm */
       /* hnum != 0 already checked.  */
       for (i = MAX_SHORTS - 1; i >= 0; i--)
        {
          work = num[i] + (carry << 8);
-         quo[i] = work / lden;
-         carry = work % lden;
+         quo[i] = work / (unsigned HOST_WIDE_INT) lden;
+         carry = work % (unsigned HOST_WIDE_INT) lden;
        }
     }
   else {                       /* full double precision,
This page took 0.064464 seconds and 5 git commands to generate.