Patchwork [wide-int] Fix exact_log2 zext test

login
register
mail settings
Submitter Richard Sandiford
Date Nov. 2, 2013, 10:19 a.m.
Message ID <87fvrfksw8.fsf@talisman.default>
Download mbox | patch
Permalink /patch/287965/
State New
Headers show

Comments

Richard Sandiford - Nov. 2, 2013, 10:19 a.m.
...which I'd fluffed when doing the wi:: conversion.

Tested on powerpc64-linux-gnu and x86_64-linux-gnu.  It fixed a spurious
gcc.dg difference on alpha-linux-gnu.  Applied as obvious.

Thanks,
Richard
Kenneth Zadeck - Nov. 2, 2013, 1:39 p.m.
On 11/02/2013 06:19 AM, Richard Sandiford wrote:
> ...which I'd fluffed when doing the wi:: conversion.
>
> Tested on powerpc64-linux-gnu and x86_64-linux-gnu.  It fixed a spurious
> gcc.dg difference on alpha-linux-gnu.  Applied as obvious.
>
> Thanks,
> Richard
>
>
> Index: gcc/wide-int.cc
> ===================================================================
> --- gcc/wide-int.cc	(revision 204311)
> +++ gcc/wide-int.cc	(working copy)
> @@ -2044,7 +2044,7 @@
>   
>     /* Get a zero-extended form of block CRUX.  */
>     unsigned HOST_WIDE_INT hwi = x.val[crux];
> -  if (crux * HOST_BITS_PER_WIDE_INT > x.precision)
> +  if ((crux + 1) * HOST_BITS_PER_WIDE_INT > x.precision)
>       hwi = zext_hwi (hwi, x.precision % HOST_BITS_PER_WIDE_INT);
>   
>     /* Now it's down to whether HWI is a power of 2.  */
ok by me.

kenny

Patch

Index: gcc/wide-int.cc
===================================================================
--- gcc/wide-int.cc	(revision 204311)
+++ gcc/wide-int.cc	(working copy)
@@ -2044,7 +2044,7 @@ 
 
   /* Get a zero-extended form of block CRUX.  */
   unsigned HOST_WIDE_INT hwi = x.val[crux];
-  if (crux * HOST_BITS_PER_WIDE_INT > x.precision)
+  if ((crux + 1) * HOST_BITS_PER_WIDE_INT > x.precision)
     hwi = zext_hwi (hwi, x.precision % HOST_BITS_PER_WIDE_INT);
 
   /* Now it's down to whether HWI is a power of 2.  */