wide-int.cc (canonize_uhwi): New function.
* wide-int.cc (canonize_uhwi): New function. (wi::divmod_internal): Use it. From-SVN: r233092
This commit is contained in:
parent
f3baa1d3ed
commit
321a2b65f8
2 changed files with 21 additions and 15 deletions
|
@ -1,3 +1,8 @@
|
|||
2016-02-02 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* wide-int.cc (canonize_uhwi): New function.
|
||||
(wi::divmod_internal): Use it.
|
||||
|
||||
2016-02-02 James Norris <jnorris@codesourcery.com
|
||||
|
||||
* gimplify.c (omp_notice_variable): Add usage check.
|
||||
|
|
|
@ -118,6 +118,20 @@ canonize (HOST_WIDE_INT *val, unsigned int len, unsigned int precision)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* VAL[0] is the unsigned result of an operation. Canonize it by adding
|
||||
another 0 block if needed, and return number of blocks needed. */
|
||||
|
||||
static inline unsigned int
|
||||
canonize_uhwi (HOST_WIDE_INT *val, unsigned int precision)
|
||||
{
|
||||
if (val[0] < 0 && precision > HOST_BITS_PER_WIDE_INT)
|
||||
{
|
||||
val[1] = 0;
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion routines in and out of wide_int.
|
||||
*/
|
||||
|
@ -1793,25 +1807,12 @@ wi::divmod_internal (HOST_WIDE_INT *quotient, unsigned int *remainder_len,
|
|||
if (quotient)
|
||||
{
|
||||
quotient[0] = o0 / o1;
|
||||
if (o1 == 1
|
||||
&& (HOST_WIDE_INT) o0 < 0
|
||||
&& dividend_prec > HOST_BITS_PER_WIDE_INT)
|
||||
{
|
||||
quotient[1] = 0;
|
||||
quotient_len = 2;
|
||||
}
|
||||
quotient_len = canonize_uhwi (quotient, dividend_prec);
|
||||
}
|
||||
if (remainder)
|
||||
{
|
||||
remainder[0] = o0 % o1;
|
||||
if ((HOST_WIDE_INT) remainder[0] < 0
|
||||
&& dividend_prec > HOST_BITS_PER_WIDE_INT)
|
||||
{
|
||||
remainder[1] = 0;
|
||||
*remainder_len = 2;
|
||||
}
|
||||
else
|
||||
*remainder_len = 1;
|
||||
*remainder_len = canonize_uhwi (remainder, dividend_prec);
|
||||
}
|
||||
return quotient_len;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue