This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/2] testsuite fixes for 16-bit targets
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: gcc-patches at gcc dot gnu dot org, richard at codesourcery dot com
- Date: Fri, 13 Jul 2007 14:51:19 +0200
- Subject: Re: [PATCH 2/2] testsuite fixes for 16-bit targets
- References: <20070704181031.GJ5690@sygehus.dk> <87tzskc52a.fsf@firetop.home>
On Wed, Jul 04, 2007 at 09:00:29PM +0100, Richard Sandiford wrote:
> Rask Ingemann Lambertsen <rask@sygehus.dk> writes:
> > The attached patch fixes 36 testsuite failures on m32c-unknown-elf. The
> > fix is to change "int" to "long int" in several places that need more than
> > 16 bits.
>
> I don't think we should do that unconditionally. It changes what's
> being tested on LP64 targets in a major way. It seems better just
> to skip the tests for 16-bit targets, and perhaps add "long int" copies
> if you think that what they're testing is useful for 16-bit targets.
Here is a patch to add those "long int" copies. For gcc.dg/pr27959-2.c, I
chose to use (u)int32_t because I'm not sure that the test will work on both
big endian and little endian targets if "long int" is 64 bits wide.
I have tested that the new tests pass on both m32c-unknown-elf and
x86_64-unknown-linux-gnu. Ok for trunk?
2007-07-13 Rask Ingemann Lambertsen <rask@sygehus.dk>
* gcc.c-torture/execute/20061101-2.c: Variant of 20061101-1.c
adapted to work on targets with 16-bit or wider int.
* gcc.c-torture/execute/pr29797-2.c: Likewise for pr29797-1.c.
* gcc.c-torture/execute/pr31448-2.c: Likewise for pr31448.c.
* gcc.dg/20061109-2.c: Likewise for 20061109-1.c.
* gcc.dg/pr27959-2.c: Likewise for pr27959.c.
Index: gcc.c-torture/execute/20061101-2.c
===================================================================
--- gcc.c-torture/execute/20061101-2.c (revision 0)
+++ gcc.c-torture/execute/20061101-2.c (revision 0)
@@ -0,0 +1,32 @@
+/* PR rtl-optimization/28970 */
+/* Origin: Peter Bergner <bergner@vnet.ibm.com> */
+
+extern void abort (void);
+
+int tar (long i)
+{
+ if (i != 36863)
+ abort ();
+
+ return -1;
+}
+
+void bug(int q, long bcount)
+{
+ int j = 0;
+ int outgo = 0;
+
+ while(j != -1)
+ {
+ outgo++;
+ if (outgo > q-1)
+ outgo = q-1;
+ j = tar (outgo*bcount);
+ }
+}
+
+int main(void)
+{
+ bug(5, 36863);
+ return 0;
+}
Index: gcc.c-torture/execute/pr29797-2.c
===================================================================
--- gcc.c-torture/execute/pr29797-2.c (revision 0)
+++ gcc.c-torture/execute/pr29797-2.c (revision 0)
@@ -0,0 +1,14 @@
+extern void abort(void);
+
+unsigned long bar(void) { return 32768; }
+
+int main()
+{
+ unsigned long nStyle = bar ();
+ if (nStyle & 32768)
+ nStyle |= 65536;
+ if (nStyle != (32768 | 65536))
+ abort ();
+ return 0;
+}
+
Index: gcc.c-torture/execute/pr31448-2.c
===================================================================
--- gcc.c-torture/execute/pr31448-2.c (revision 0)
+++ gcc.c-torture/execute/pr31448-2.c (revision 0)
@@ -0,0 +1,36 @@
+/* PR middle-end/31448, this used to ICE during expand because
+ reduce_to_bit_field_precision was not ready to handle constants. */
+
+typedef struct _st {
+ long int iIndex : 24;
+ long int iIndex1 : 24;
+} st;
+st *next;
+void g(void)
+{
+ st *next = 0;
+ int nIndx;
+ const static int constreg[] = { 0,};
+ nIndx = 0;
+ next->iIndex = constreg[nIndx];
+}
+void f(void)
+{
+ int nIndx;
+ const static long int constreg[] = { 0xFEFEFEFE,};
+ nIndx = 0;
+ next->iIndex = constreg[nIndx];
+ next->iIndex1 = constreg[nIndx];
+}
+int main(void)
+{
+ st a;
+ next = &a;
+ f();
+ if (next->iIndex != 0xFFFEFEFE)
+ __builtin_abort ();
+ if (next->iIndex1 != 0xFFFEFEFE)
+ __builtin_abort ();
+ return 0;
+}
+
Index: gcc.dg/20061109-2.c
===================================================================
--- gcc.dg/20061109-2.c (revision 0)
+++ gcc.dg/20061109-2.c (revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+/* This assignment might be implemented with a mem copy from the
+ literal pool with two BLKmode operands. This produced an ICE on S/390
+ since simplify_subreg was called for such a BLKmode operand. */
+
+struct a
+{
+ unsigned long b:24;
+};
+
+void
+foo (struct a *t)
+{
+ t->b = 32;
+}
Index: gcc.dg/pr27959-2.c
===================================================================
--- gcc.dg/pr27959-2.c (revision 0)
+++ gcc.dg/pr27959-2.c (revision 0)
@@ -0,0 +1,94 @@
+/* PR middle-end/27959 */
+/* { dg-do run { target { stdint_types } } } */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -mtune=z990" { target s390*-*-* } } */
+
+#include <stdint.h>
+extern void abort (void);
+
+struct B
+{
+ unsigned int b1, b2, b3;
+ char b4;
+};
+
+struct C
+{
+ char c1;
+};
+
+struct D
+{
+ char *d1;
+ struct C **d2;
+ unsigned int d3;
+};
+
+void
+__attribute__((noinline))
+foo (void *x, struct B *y, unsigned int *z)
+{
+ if (x)
+ abort ();
+ if (y->b1 != 7 || y->b2 != 5 || y->b3 != 3 || y->b4)
+ abort ();
+ if (*z != 2)
+ abort ();
+}
+
+int
+__attribute__((noinline))
+baz (unsigned int *x, unsigned int y)
+{
+ asm volatile ("" : : "r" (&x), "r" (&y) : "memory");
+ return *x + y;
+}
+
+inline int bar (unsigned int *x, unsigned int y)
+{
+ if (y < *x)
+ return 0;
+ return baz (x, y);
+}
+
+unsigned int *
+__attribute__((noinline))
+test (struct D *x, unsigned int *y)
+{
+ struct B b;
+ uint32_t c;
+
+ bar (y, x->d3);
+ if ((*(x->d2))->c1)
+ c = ((uint32_t) x->d1[0]
+ + ((uint32_t) x->d1[1] << 8)
+ + ((uint32_t) x->d1[2] << 16)
+ + ((uint32_t) x->d1[3] << 24));
+ else
+ {
+ int32_t d;
+ ((char *) &d)[0] = x->d1[0];
+ ((char *) &d)[1] = x->d1[1];
+ ((char *) &d)[2] = x->d1[2];
+ ((char *) &d)[3] = x->d1[3];
+ c = d;
+ }
+ b.b4 = 0;
+ b.b1 = c / 10000L % 10000;
+ b.b2 = c / 100 % 100;
+ b.b3 = c % 100;
+ foo (0, &b, y);
+ return y;
+}
+
+int
+main (void)
+{
+ uint32_t x = 900070503;
+ unsigned int y = 2;
+ struct C c = { 0 }, *cptr = &c;
+ struct D d = { (char *) &x, &cptr, 0 };
+ if (test (&d, &y) != &y)
+ abort ();
+ return 0;
+}
--
Rask Ingemann Lambertsen