diff mbox

[testsuite,committed] Fix 16-bit int test (PR52641)

Message ID 51348253.9000506@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay March 4, 2013, 11:15 a.m. UTC
http://gcc.gnu.org/r196428

Fixed this test case that assumed int is always 32 bits at least.

       PR testsuite/52641
       PR tree-optimization/52631
       * gcc.dg/tree-ssa/pr52631.c: Fix 16-bit int.

Johann

Comments

Jakub Jelinek March 4, 2013, 11:20 a.m. UTC | #1
On Mon, Mar 04, 2013 at 12:15:31PM +0100, Georg-Johann Lay wrote:
> http://gcc.gnu.org/r196428
> 
> Fixed this test case that assumed int is always 32 bits at least.
> 
>        PR testsuite/52641
>        PR tree-optimization/52631
>        * gcc.dg/tree-ssa/pr52631.c: Fix 16-bit int.
> 
> --- gcc.dg/tree-ssa/pr52631.c   (revision 196329)
> +++ gcc.dg/tree-ssa/pr52631.c   (working copy)
> @@ -3,7 +3,11 @@
> 
>  unsigned f(unsigned a)
>  {
> +#if __SIZEOF_INT__ == 2
> +  unsigned b = a >> 15;
> +#else
>    unsigned b = a >> 31;
> +#endif

So perhaps better
  unsigned b = a >> (__SIZEOF_INT__ * __CHAR_BIT__ - 1);
?

	Jakub
Georg-Johann Lay March 4, 2013, 11:36 a.m. UTC | #2
Jakub Jelinek wrote:
> On Mon, Mar 04, 2013 at 12:15:31PM +0100, Georg-Johann Lay wrote:
>> http://gcc.gnu.org/r196428
>>
>> Fixed this test case that assumed int is always 32 bits at least.
>>
>>        PR testsuite/52641
>>        PR tree-optimization/52631
>>        * gcc.dg/tree-ssa/pr52631.c: Fix 16-bit int.
>>
>> --- gcc.dg/tree-ssa/pr52631.c   (revision 196329)
>> +++ gcc.dg/tree-ssa/pr52631.c   (working copy)
>> @@ -3,7 +3,11 @@
>>
>>  unsigned f(unsigned a)
>>  {
>> +#if __SIZEOF_INT__ == 2
>> +  unsigned b = a >> 15;
>> +#else
>>    unsigned b = a >> 31;
>> +#endif
> 
> So perhaps better
>   unsigned b = a >> (__SIZEOF_INT__ * __CHAR_BIT__ - 1);
> ?


Yes, maybe.  I just fixed the int=16 case, dunno what the optimization pass is
supposed to do with 64-bit integers...

Johann
diff mbox

Patch

Index: gcc.dg/tree-ssa/pr52631.c
===================================================================
--- gcc.dg/tree-ssa/pr52631.c   (revision 196329)
+++ gcc.dg/tree-ssa/pr52631.c   (working copy)
@@ -3,7 +3,11 @@ 

 unsigned f(unsigned a)
 {
+#if __SIZEOF_INT__ == 2
+  unsigned b = a >> 15;
+#else
   unsigned b = a >> 31;
+#endif
   return b&1;
 }