Commit 321a2b65 by Jakub Jelinek Committed by Jakub Jelinek

wide-int.cc (canonize_uhwi): New function.

	* wide-int.cc (canonize_uhwi): New function.
	(wi::divmod_internal): Use it.

From-SVN: r233092
parent f3baa1d3
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 2016-02-02 James Norris <jnorris@codesourcery.com
* gimplify.c (omp_notice_variable): Add usage check. * gimplify.c (omp_notice_variable): Add usage check.
......
...@@ -118,6 +118,20 @@ canonize (HOST_WIDE_INT *val, unsigned int len, unsigned int precision) ...@@ -118,6 +118,20 @@ canonize (HOST_WIDE_INT *val, unsigned int len, unsigned int precision)
return 1; 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. * Conversion routines in and out of wide_int.
*/ */
...@@ -1793,25 +1807,12 @@ wi::divmod_internal (HOST_WIDE_INT *quotient, unsigned int *remainder_len, ...@@ -1793,25 +1807,12 @@ wi::divmod_internal (HOST_WIDE_INT *quotient, unsigned int *remainder_len,
if (quotient) if (quotient)
{ {
quotient[0] = o0 / o1; quotient[0] = o0 / o1;
if (o1 == 1 quotient_len = canonize_uhwi (quotient, dividend_prec);
&& (HOST_WIDE_INT) o0 < 0
&& dividend_prec > HOST_BITS_PER_WIDE_INT)
{
quotient[1] = 0;
quotient_len = 2;
}
} }
if (remainder) if (remainder)
{ {
remainder[0] = o0 % o1; remainder[0] = o0 % o1;
if ((HOST_WIDE_INT) remainder[0] < 0 *remainder_len = canonize_uhwi (remainder, dividend_prec);
&& dividend_prec > HOST_BITS_PER_WIDE_INT)
{
remainder[1] = 0;
*remainder_len = 2;
}
else
*remainder_len = 1;
} }
return quotient_len; return quotient_len;
} }
......
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