This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][testsuite] Fix fold-eqandshift-1.c when int is not 32 bits
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Aug 2007 15:49:14 +0200
- Subject: [PATCH][testsuite] Fix fold-eqandshift-1.c when int is not 32 bits
This fixes three testsuite failures on targets where int not 32 bits wide
by making the shift count relative to the width of int. Tested on
m32c-unknown-elf and x86_64-unknown-linux-gnu.
:ADDPATCH testsuite:
2007-08-28 Rask Ingemann Lambertsen <rask@sygehus.dk>
* gcc.dg/fold-eqandshift-1.c (INT_BITS): New.
(test5)(test6): Use it.
Index: gcc/testsuite/gcc.dg/fold-eqandshift-1.c
===================================================================
--- gcc/testsuite/gcc.dg/fold-eqandshift-1.c (revision 127806)
+++ gcc/testsuite/gcc.dg/fold-eqandshift-1.c (working copy)
@@ -25,15 +25,25 @@
return (d >> 3) & 4;
}
+#if __INT_MAX__ == 32767
+#define INT_BITS 16
+#elif __INT_MAX__ == 2147483647
+#define INT_BITS 32
+#elif __INT_MAX__ == 9223372036854775807
+#define INT_BITS 64
+#else
+#error Please add support for your target here.
+#endif
+
void test5(int e)
{
- if ((e >> 31) & 64)
+ if ((e >> (INT_BITS - 1)) & 64)
foo();
}
void test6(unsigned int f)
{
- if ((f >> 31) & 64)
+ if ((f >> (INT_BITS - 1)) & 64)
foo();
}