diff mbox

[wide-int,3/5] Fix large widths in shifted_mask

Message ID 878uqtedcl.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford April 25, 2014, 1:40 p.m. UTC
Very minor, but since shifted_mask copes with out-of-range widths,
I think mask should too.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard

Comments

Kenneth Zadeck April 25, 2014, 5:34 p.m. UTC | #1
richard,

I think that this patch is fine as is.    but in looking at the 
surrounding code, i saw something that appears to be somewhat troubling.

I am worried about the two asserts.   Given that we now require that 
some users write code similar to the code in tree-vrp.c:2628, it seems 
that these asserts are only latent land mines.

kenny
On 04/25/2014 09:40 AM, Richard Sandiford wrote:
> Very minor, but since shifted_mask copes with out-of-range widths,
> I think mask should too.
>
> Tested on x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> Index: gcc/wide-int.cc
> ===================================================================
> --- gcc/wide-int.cc	2014-04-25 09:26:57.025944460 +0100
> +++ gcc/wide-int.cc	2014-04-25 09:37:16.873811137 +0100
> @@ -716,7 +716,7 @@ wi::mask (HOST_WIDE_INT *val, unsigned i
>     gcc_assert (width < 4 * MAX_BITSIZE_MODE_ANY_INT);
>     gcc_assert (prec <= 4 * MAX_BITSIZE_MODE_ANY_INT);
>   
> -  if (width == prec)
> +  if (width >= prec)
>       {
>         val[0] = negate ? 0 : -1;
>         return 1;
Kenneth Zadeck April 26, 2014, 2:50 a.m. UTC | #2
approved
On 04/25/2014 09:40 AM, Richard Sandiford wrote:
> Very minor, but since shifted_mask copes with out-of-range widths,
> I think mask should too.
>
> Tested on x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> Index: gcc/wide-int.cc
> ===================================================================
> --- gcc/wide-int.cc	2014-04-25 09:26:57.025944460 +0100
> +++ gcc/wide-int.cc	2014-04-25 09:37:16.873811137 +0100
> @@ -716,7 +716,7 @@ wi::mask (HOST_WIDE_INT *val, unsigned i
>     gcc_assert (width < 4 * MAX_BITSIZE_MODE_ANY_INT);
>     gcc_assert (prec <= 4 * MAX_BITSIZE_MODE_ANY_INT);
>   
> -  if (width == prec)
> +  if (width >= prec)
>       {
>         val[0] = negate ? 0 : -1;
>         return 1;
Richard Sandiford April 27, 2014, 10:30 a.m. UTC | #3
Kenneth Zadeck <zadeck@naturalbridge.com> writes:
> I think that this patch is fine as is.    but in looking at the 
> surrounding code, i saw something that appears to be somewhat troubling.
>
> I am worried about the two asserts.   Given that we now require that 
> some users write code similar to the code in tree-vrp.c:2628, it seems 
> that these asserts are only latent land mines.

Yeah, they should probably go.  OK to remove them?

Thanks,
Richard
diff mbox

Patch

Index: gcc/wide-int.cc
===================================================================
--- gcc/wide-int.cc	2014-04-25 09:26:57.025944460 +0100
+++ gcc/wide-int.cc	2014-04-25 09:37:16.873811137 +0100
@@ -716,7 +716,7 @@  wi::mask (HOST_WIDE_INT *val, unsigned i
   gcc_assert (width < 4 * MAX_BITSIZE_MODE_ANY_INT);
   gcc_assert (prec <= 4 * MAX_BITSIZE_MODE_ANY_INT);
 
-  if (width == prec)
+  if (width >= prec)
     {
       val[0] = negate ? 0 : -1;
       return 1;