diff mbox

[wide-int] Make integer_onep return false for signed 1-bit bitfields

Message ID 87li14h6nw.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford Nov. 4, 2013, 9:12 a.m. UTC
As discussed on gcc@, integer_onep is supposed to return false for
a nonzero 1-bit value if the type is signed.

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

Thanks,
Richard

Comments

Richard Sandiford Nov. 6, 2013, 10:31 p.m. UTC | #1
Ping.

Richard Sandiford <rdsandiford@googlemail.com> writes:
> As discussed on gcc@, integer_onep is supposed to return false for
> a nonzero 1-bit value if the type is signed.
>
> Tested on x86_64-linux-gnu and powerpc64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> Index: gcc/tree.c
> ===================================================================
> --- gcc/tree.c	2013-10-29 19:19:27.623468618 +0000
> +++ gcc/tree.c	2013-11-02 17:25:06.499657501 +0000
> @@ -2092,7 +2092,7 @@ integer_onep (const_tree expr)
>    switch (TREE_CODE (expr))
>      {
>      case INTEGER_CST:
> -      return wi::eq_p (expr, 1);
> +      return wi::eq_p (wi::to_widest (expr), 1);
>      case COMPLEX_CST:
>        return (integer_onep (TREE_REALPART (expr))
>  	      && integer_zerop (TREE_IMAGPART (expr)));
Richard Biener Nov. 7, 2013, 10:34 a.m. UTC | #2
On Wed, Nov 6, 2013 at 11:31 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> Ping.

Ok.

Thanks,
Richard.

> Richard Sandiford <rdsandiford@googlemail.com> writes:
>> As discussed on gcc@, integer_onep is supposed to return false for
>> a nonzero 1-bit value if the type is signed.
>>
>> Tested on x86_64-linux-gnu and powerpc64-linux-gnu.  OK to install?
>>
>> Thanks,
>> Richard
>>
>>
>> Index: gcc/tree.c
>> ===================================================================
>> --- gcc/tree.c        2013-10-29 19:19:27.623468618 +0000
>> +++ gcc/tree.c        2013-11-02 17:25:06.499657501 +0000
>> @@ -2092,7 +2092,7 @@ integer_onep (const_tree expr)
>>    switch (TREE_CODE (expr))
>>      {
>>      case INTEGER_CST:
>> -      return wi::eq_p (expr, 1);
>> +      return wi::eq_p (wi::to_widest (expr), 1);
>>      case COMPLEX_CST:
>>        return (integer_onep (TREE_REALPART (expr))
>>             && integer_zerop (TREE_IMAGPART (expr)));
diff mbox

Patch

Index: gcc/tree.c
===================================================================
--- gcc/tree.c	2013-10-29 19:19:27.623468618 +0000
+++ gcc/tree.c	2013-11-02 17:25:06.499657501 +0000
@@ -2092,7 +2092,7 @@  integer_onep (const_tree expr)
   switch (TREE_CODE (expr))
     {
     case INTEGER_CST:
-      return wi::eq_p (expr, 1);
+      return wi::eq_p (wi::to_widest (expr), 1);
     case COMPLEX_CST:
       return (integer_onep (TREE_REALPART (expr))
 	      && integer_zerop (TREE_IMAGPART (expr)));