[PATCH][testsuite] Fix fold-eqandshift-1.c when int is not 32 bits
Rask Ingemann Lambertsen
rask@sygehus.dk
Tue Aug 28 14:13:00 GMT 2007
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();
}
More information about the Gcc-patches
mailing list