diff mbox

RFA: Fix some gcc tests for 16-bit targets

Message ID 8738jhvfgj.fsf@redhat.com
State New
Headers show

Commit Message

Nick Clifton Feb. 17, 2014, 5:03 p.m. UTC
Hi Guys,

  There are several tests in the gcc testsuite which implicitly assume a
  32-bit (or larger) target.  The patch below provides fixes for these
  tests in a variety of different ways.  Where possible I have tried to
  recode the test so that it will compile on a 16-bit target, but in a
  couple of cases the test itself is too big, and so I have added a
  requirement on a 32-bit+ target.

  Tested with no regressions on an i686-pc-linux-gnu and an
  x86_64-pc-linux-gnu toolchain, and with reduction in the number of
  unexpected failures for rl78-elf, rx-elf and msp430-elf toolchains.

  OK to apply ?

Cheers
  Nick

gcc/testsuite/ChangeLog
2014-02-17  Nick Clifton  <nickc@redhat.com>

	* gcc.dg/c-torture/execute/pr43220.c: Use a long integer to
	count the iterations.
        * gcc.c-torture/execute/pr58570.c: Use a long integer to hold a
	29-bit bitfield.
        * gcc.c-torture/unsorted/DFcmp.c: Use smaller arrays on 16-bit
	targets.
        * gcc.c-torture/unsorted/SFset.c: Likewise.
        * gcc.dg/graphite/pr46966.c: Require a 32-bit plus target - it
	is too big for smaller targets.
        * gcc.dg/pr23623.c: Use a long integer to hold 31-bit
	bitfields.
        * gcc.dg/pr48784-1.c: Use a long integer to hold a 28-bit
	bitfield.
        * gcc.dg/pr48784-2.c: Likewise.
        * gcc.dg/pr56997-2.c: Use a long integer as the test_type on
	16-bit targets.
        * gcc.dg/pr59471.c: Use a long integer as the 32-bit vector type
	on 16-bit targets.
        * gcc.dg/sms-6.c: Use a long integer as the array_type on
	16-bit targets.
        * gcc.dg/torture/vec-cvt-1.c: Require a 32-bit plus target - it
	is too big for smaller targets.

Comments

DJ Delorie Feb. 17, 2014, 8:01 p.m. UTC | #1
>  struct S
>  {
>    int f0:15;
> -  int f1:29;
> +  long int f1:29;
>  };

IIRC if you change one field here, you need to change both as some
targets won't pack fields together if the types don't match.

Likewise for other struct-field cases.
Richard Biener Feb. 17, 2014, 8:12 p.m. UTC | #2
On February 17, 2014 6:03:56 PM GMT+01:00, Nick Clifton <nickc@redhat.com> wrote:
>Hi Guys,
>
> There are several tests in the gcc testsuite which implicitly assume a
>  32-bit (or larger) target.  The patch below provides fixes for these
>  tests in a variety of different ways.  Where possible I have tried to
>  recode the test so that it will compile on a 16-bit target, but in a
>  couple of cases the test itself is too big, and so I have added a
>  requirement on a 32-bit+ target.
>
>  Tested with no regressions on an i686-pc-linux-gnu and an
>  x86_64-pc-linux-gnu toolchain, and with reduction in the number of
>  unexpected failures for rl78-elf, rx-elf and msp430-elf toolchains.
>
>  OK to apply ?

Instead of modifying testcases I'd be less nervous if you'd make them require 32bit. Otherwise you should reproduce the original issues with the modified testcases.

Thanks,
Richard.

>Cheers
>  Nick
>
>gcc/testsuite/ChangeLog
>2014-02-17  Nick Clifton  <nickc@redhat.com>
>
>	* gcc.dg/c-torture/execute/pr43220.c: Use a long integer to
>	count the iterations.
>        * gcc.c-torture/execute/pr58570.c: Use a long integer to hold a
>	29-bit bitfield.
>        * gcc.c-torture/unsorted/DFcmp.c: Use smaller arrays on 16-bit
>	targets.
>        * gcc.c-torture/unsorted/SFset.c: Likewise.
>        * gcc.dg/graphite/pr46966.c: Require a 32-bit plus target - it
>	is too big for smaller targets.
>        * gcc.dg/pr23623.c: Use a long integer to hold 31-bit
>	bitfields.
>        * gcc.dg/pr48784-1.c: Use a long integer to hold a 28-bit
>	bitfield.
>        * gcc.dg/pr48784-2.c: Likewise.
>        * gcc.dg/pr56997-2.c: Use a long integer as the test_type on
>	16-bit targets.
>       * gcc.dg/pr59471.c: Use a long integer as the 32-bit vector type
>	on 16-bit targets.
>        * gcc.dg/sms-6.c: Use a long integer as the array_type on
>	16-bit targets.
>        * gcc.dg/torture/vec-cvt-1.c: Require a 32-bit plus target - it
>	is too big for smaller targets.
>
>Index: gcc/testsuite/gcc.c-torture/execute/pr43220.c
>===================================================================
>--- gcc/testsuite/gcc.c-torture/execute/pr43220.c	(revision 207817)
>+++ gcc/testsuite/gcc.c-torture/execute/pr43220.c	(working copy)
>@@ -3,7 +3,7 @@
> int
> main (void)
> {
>-  int n = 0;
>+  long int n = 0;
> lab:;
>     {
>       int x[n % 1000 + 1];
>Index: gcc/testsuite/gcc.c-torture/execute/pr58570.c
>===================================================================
>--- gcc/testsuite/gcc.c-torture/execute/pr58570.c	(revision 207817)
>+++ gcc/testsuite/gcc.c-torture/execute/pr58570.c	(working copy)
>@@ -2,7 +2,7 @@
> struct S
> {
>   int f0:15;
>-  int f1:29;
>+  long int f1:29;
> };
> 
> int e = 1, i;
>Index: gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c
>===================================================================
>--- gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c	(revision 207817)
>+++ gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c	(working copy)
>@@ -22,6 +22,17 @@
> #define adrx1 (E1[x1])
> #define regx1 (p1[x1])
> 
>+#if __SIZEOF_INT__ <= 2
>+#undef  E0
>+#define E0      ((type *)10000)
>+#undef  adrreg0
>+#define adrreg0 (p0[10000])
>+#undef  E1
>+#define E1      ((type *)(1111 & ~(__alignof__ (type) - 1)))
>+#undef  adrreg1
>+#define adrreg1 (p1[1111/4])
>+#endif
>+
> reg0reg1 (r0, r1, x0, x1, p0, p1)
> type r0, r1;  type *p0, *p1;
> {if (reg0 <= reg1) return 1; else return 0;}
>Index: gcc/testsuite/gcc.c-torture/unsorted/SFset.c
>===================================================================
>--- gcc/testsuite/gcc.c-torture/unsorted/SFset.c	(revision 207817)
>+++ gcc/testsuite/gcc.c-torture/unsorted/SFset.c	(working copy)
>@@ -18,6 +18,17 @@
> #define adrx1 (E1[x1])
> #define regx1 (p1[x1])
> 
>+#if __SIZEOF_INT__ <= 2
>+#undef  E0
>+#define E0      ((type *)10000)
>+#undef  adrreg0
>+#define adrreg0 (p0[10000])
>+#undef  E1
>+#define E1      ((type *)(1111 & ~(__alignof__ (type) - 1)))
>+#undef  adrreg1
>+#define adrreg1 (p1[1111/4])
>+#endif
>+
> int glob0, glob1;
> 
> #define type float
>Index: gcc/testsuite/gcc.dg/graphite/pr46966.c
>===================================================================
>--- gcc/testsuite/gcc.dg/graphite/pr46966.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/graphite/pr46966.c	(working copy)
>@@ -1,5 +1,7 @@
> /* PR tree-optimization/46966 */
> /* { dg-do compile } */
>+/* This test is too big for small targets.  */
>+/* { dg-require-effective-target size32plus } */
>/* { dg-options "-O -floop-interchange -ffast-math -fno-tree-copy-prop
>-fno-tree-loop-im" } */
> 
> int a[1000][1000];
>Index: gcc/testsuite/gcc.dg/pr23623.c
>===================================================================
>--- gcc/testsuite/gcc.dg/pr23623.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/pr23623.c	(working copy)
>@@ -8,19 +8,19 @@
> extern struct
> {
>   unsigned int b : 1;
>-  unsigned int : 31;
>+  unsigned long int : 31;
> } bf1;
> 
> extern volatile struct
> {
>   unsigned int b : 1;
>-  unsigned int : 31;
>+  unsigned long int : 31;
> } bf2;
> 
> extern struct
> {
>   volatile unsigned int b : 1;
>-  volatile unsigned int : 31;
>+  volatile unsigned long int : 31;
> } bf3;
> 
> void writeb(void)
>@@ -45,4 +45,3 @@
>    variable, we need to give a count of 12 instead of 6 here.  */
> /* { dg-final { scan-rtl-dump-times "mem/v(/.)*:SI" 12 "final" } } */
> /* { dg-final { cleanup-rtl-dump "final" } } */
>-
>Index: gcc/testsuite/gcc.dg/pr48784-1.c
>===================================================================
>--- gcc/testsuite/gcc.dg/pr48784-1.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/pr48784-1.c	(working copy)
>@@ -6,13 +6,13 @@
> #pragma pack(1)
> volatile struct S0 {
>    signed a : 7;
>-   unsigned b : 28;  /* b can't be fetched with an aligned 32-bit
>access, */
>+   unsigned long b : 28;  /* b can't be fetched with an aligned 32-bit
>access, */
>         /* but it certainly can be fetched with an unaligned access */
>-} g = {0,0xfffffff};
>+} g = {0,0xfffffffUL};
> 
> int main() {
>-  unsigned b = g.b;
>-  if (b != 0xfffffff)
>+  unsigned long b = g.b;
>+  if (b != 0xfffffffUL)
>     abort ();
>   return 0;
> }
>Index: gcc/testsuite/gcc.dg/pr48784-2.c
>===================================================================
>--- gcc/testsuite/gcc.dg/pr48784-2.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/pr48784-2.c	(working copy)
>@@ -6,13 +6,13 @@
> #pragma pack(1)
> volatile struct S0 {
>    signed a : 7;
>-   unsigned b : 28;  /* b can't be fetched with an aligned 32-bit
>access, */
>+   unsigned long b : 28;  /* b can't be fetched with an aligned 32-bit
>access, */
>         /* but it certainly can be fetched with an unaligned access */
>-} g = {0,0xfffffff};
>+} g = {0,0xfffffffUL};
> 
> int main() {
>-  unsigned b = g.b;
>-  if (b != 0xfffffff)
>+  unsigned long b = g.b;
>+  if (b != 0xfffffffUL)
>     abort ();
>   return 0;
> }
>Index: gcc/testsuite/gcc.dg/pr56997-2.c
>===================================================================
>--- gcc/testsuite/gcc.dg/pr56997-2.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/pr56997-2.c	(working copy)
>@@ -4,8 +4,13 @@
> 
> extern void abort (void);
> 
>+#if __SIZEOF_INT__ <= 2
>+#define test_type unsigned long
>+#define MAGIC 0x1020304ul
>+#else
> #define test_type unsigned int
> #define MAGIC 0x1020304u
>+#endif
> 
> typedef struct s{
>  unsigned char Prefix;
>Index: gcc/testsuite/gcc.dg/pr59471.c
>===================================================================
>--- gcc/testsuite/gcc.dg/pr59471.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/pr59471.c	(working copy)
>@@ -6,8 +6,13 @@
> typedef unsigned short uint16x8_t
> __attribute__ ((__vector_size__ (16)));
> 
>+#if __SIZEOF_INT__ <= 2
>+typedef unsigned long int uint32x4_t
>+__attribute__ ((__vector_size__ (16)));
>+#else
> typedef unsigned int uint32x4_t
> __attribute__ ((__vector_size__ (16)));
>+#endif
> 
> void
> foo (uint16x8_t *x, uint8x4_t *y)
>Index: gcc/testsuite/gcc.dg/sms-6.c
>===================================================================
>--- gcc/testsuite/gcc.dg/sms-6.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/sms-6.c	(working copy)
>@@ -2,10 +2,16 @@
>/* { dg-options "-O2 -fmodulo-sched -fdump-rtl-sms --param
>sms-min-sc=1" } */
>/* { dg-options "-O2 -fmodulo-sched -fdump-rtl-sms --param sms-min-sc=1
>-fmodulo-sched-allow-regmoves" { target powerpc*-*-* } } */
> 
>+#if (__SIZEOF_INT__ <= 2)
>+typedef long int array_type;
>+#else
>+typedef int array_type;
>+#endif
>+
> extern void abort (void);
> 
> __attribute__ ((noinline))
>-void foo (int * __restrict__ a, int * __restrict__ b, int *
>__restrict__ c)
>+void foo (array_type * __restrict__ a, array_type * __restrict__ b,
>array_type * __restrict__ c)
> {
>    int i;
>    for(i = 0; i < 100; i+=4)
>@@ -17,16 +23,13 @@
>      }
> }   
> 
>+array_type a[100], b[100], c[100];
> 
>-int a[100], b[100], c[100];
> int main()
> {
>-#if (__SIZEOF_INT__ <= 2)
>   int i;
>-  long res;
>-#else
>-  int i, res;
>-#endif  
>+  array_type res;
>+
>   for(i = 0; i < 100; i++)
>     {
>       b[i] = c[i] = i;
>@@ -47,4 +50,3 @@
>/* { dg-final { scan-rtl-dump-times "SMS succeeded" 1 "sms" { target
>spu-*-* } } } */
>/* { dg-final { scan-rtl-dump-times "SMS succeeded" 3 "sms" { target
>powerpc*-*-* } } } */
> /* { dg-final { cleanup-rtl-dump "sms" } } */
>-
>Index: gcc/testsuite/gcc.dg/torture/vec-cvt-1.c
>===================================================================
>--- gcc/testsuite/gcc.dg/torture/vec-cvt-1.c	(revision 207817)
>+++ gcc/testsuite/gcc.dg/torture/vec-cvt-1.c	(working copy)
>@@ -1,4 +1,6 @@
> /* { dg-do run } */
>+/* This test is too big for small targets.  */
>+/* { dg-require-effective-target size32plus } */
> 
> #include <stdlib.h>
>
diff mbox

Patch

Index: gcc/testsuite/gcc.c-torture/execute/pr43220.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/pr43220.c	(revision 207817)
+++ gcc/testsuite/gcc.c-torture/execute/pr43220.c	(working copy)
@@ -3,7 +3,7 @@ 
 int
 main (void)
 {
-  int n = 0;
+  long int n = 0;
 lab:;
     {
       int x[n % 1000 + 1];
Index: gcc/testsuite/gcc.c-torture/execute/pr58570.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/pr58570.c	(revision 207817)
+++ gcc/testsuite/gcc.c-torture/execute/pr58570.c	(working copy)
@@ -2,7 +2,7 @@ 
 struct S
 {
   int f0:15;
-  int f1:29;
+  long int f1:29;
 };
 
 int e = 1, i;
Index: gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c	(revision 207817)
+++ gcc/testsuite/gcc.c-torture/unsorted/DFcmp.c	(working copy)
@@ -22,6 +22,17 @@ 
 #define adrx1 (E1[x1])
 #define regx1 (p1[x1])
 
+#if __SIZEOF_INT__ <= 2
+#undef  E0
+#define E0      ((type *)10000)
+#undef  adrreg0
+#define adrreg0 (p0[10000])
+#undef  E1
+#define E1      ((type *)(1111 & ~(__alignof__ (type) - 1)))
+#undef  adrreg1
+#define adrreg1 (p1[1111/4])
+#endif
+
 reg0reg1 (r0, r1, x0, x1, p0, p1)
 type r0, r1;  type *p0, *p1;
 {if (reg0 <= reg1) return 1; else return 0;}
Index: gcc/testsuite/gcc.c-torture/unsorted/SFset.c
===================================================================
--- gcc/testsuite/gcc.c-torture/unsorted/SFset.c	(revision 207817)
+++ gcc/testsuite/gcc.c-torture/unsorted/SFset.c	(working copy)
@@ -18,6 +18,17 @@ 
 #define adrx1 (E1[x1])
 #define regx1 (p1[x1])
 
+#if __SIZEOF_INT__ <= 2
+#undef  E0
+#define E0      ((type *)10000)
+#undef  adrreg0
+#define adrreg0 (p0[10000])
+#undef  E1
+#define E1      ((type *)(1111 & ~(__alignof__ (type) - 1)))
+#undef  adrreg1
+#define adrreg1 (p1[1111/4])
+#endif
+
 int glob0, glob1;
 
 #define type float
Index: gcc/testsuite/gcc.dg/graphite/pr46966.c
===================================================================
--- gcc/testsuite/gcc.dg/graphite/pr46966.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/graphite/pr46966.c	(working copy)
@@ -1,5 +1,7 @@ 
 /* PR tree-optimization/46966 */
 /* { dg-do compile } */
+/* This test is too big for small targets.  */
+/* { dg-require-effective-target size32plus } */
 /* { dg-options "-O -floop-interchange -ffast-math -fno-tree-copy-prop -fno-tree-loop-im" } */
 
 int a[1000][1000];
Index: gcc/testsuite/gcc.dg/pr23623.c
===================================================================
--- gcc/testsuite/gcc.dg/pr23623.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/pr23623.c	(working copy)
@@ -8,19 +8,19 @@ 
 extern struct
 {
   unsigned int b : 1;
-  unsigned int : 31;
+  unsigned long int : 31;
 } bf1;
 
 extern volatile struct
 {
   unsigned int b : 1;
-  unsigned int : 31;
+  unsigned long int : 31;
 } bf2;
 
 extern struct
 {
   volatile unsigned int b : 1;
-  volatile unsigned int : 31;
+  volatile unsigned long int : 31;
 } bf3;
 
 void writeb(void)
@@ -45,4 +45,3 @@ 
    variable, we need to give a count of 12 instead of 6 here.  */
 /* { dg-final { scan-rtl-dump-times "mem/v(/.)*:SI" 12 "final" } } */
 /* { dg-final { cleanup-rtl-dump "final" } } */
-
Index: gcc/testsuite/gcc.dg/pr48784-1.c
===================================================================
--- gcc/testsuite/gcc.dg/pr48784-1.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/pr48784-1.c	(working copy)
@@ -6,13 +6,13 @@ 
 #pragma pack(1)
 volatile struct S0 {
    signed a : 7;
-   unsigned b : 28;  /* b can't be fetched with an aligned 32-bit access, */
+   unsigned long b : 28;  /* b can't be fetched with an aligned 32-bit access, */
                      /* but it certainly can be fetched with an unaligned access */
-} g = {0,0xfffffff};
+} g = {0,0xfffffffUL};
 
 int main() {
-  unsigned b = g.b;
-  if (b != 0xfffffff)
+  unsigned long b = g.b;
+  if (b != 0xfffffffUL)
     abort ();
   return 0;
 }
Index: gcc/testsuite/gcc.dg/pr48784-2.c
===================================================================
--- gcc/testsuite/gcc.dg/pr48784-2.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/pr48784-2.c	(working copy)
@@ -6,13 +6,13 @@ 
 #pragma pack(1)
 volatile struct S0 {
    signed a : 7;
-   unsigned b : 28;  /* b can't be fetched with an aligned 32-bit access, */
+   unsigned long b : 28;  /* b can't be fetched with an aligned 32-bit access, */
                      /* but it certainly can be fetched with an unaligned access */
-} g = {0,0xfffffff};
+} g = {0,0xfffffffUL};
 
 int main() {
-  unsigned b = g.b;
-  if (b != 0xfffffff)
+  unsigned long b = g.b;
+  if (b != 0xfffffffUL)
     abort ();
   return 0;
 }
Index: gcc/testsuite/gcc.dg/pr56997-2.c
===================================================================
--- gcc/testsuite/gcc.dg/pr56997-2.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/pr56997-2.c	(working copy)
@@ -4,8 +4,13 @@ 
 
 extern void abort (void);
 
+#if __SIZEOF_INT__ <= 2
+#define test_type unsigned long
+#define MAGIC 0x1020304ul
+#else
 #define test_type unsigned int
 #define MAGIC 0x1020304u
+#endif
 
 typedef struct s{
  unsigned char Prefix;
Index: gcc/testsuite/gcc.dg/pr59471.c
===================================================================
--- gcc/testsuite/gcc.dg/pr59471.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/pr59471.c	(working copy)
@@ -6,8 +6,13 @@ 
 typedef unsigned short uint16x8_t
 __attribute__ ((__vector_size__ (16)));
 
+#if __SIZEOF_INT__ <= 2
+typedef unsigned long int uint32x4_t
+__attribute__ ((__vector_size__ (16)));
+#else
 typedef unsigned int uint32x4_t
 __attribute__ ((__vector_size__ (16)));
+#endif
 
 void
 foo (uint16x8_t *x, uint8x4_t *y)
Index: gcc/testsuite/gcc.dg/sms-6.c
===================================================================
--- gcc/testsuite/gcc.dg/sms-6.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/sms-6.c	(working copy)
@@ -2,10 +2,16 @@ 
 /* { dg-options "-O2 -fmodulo-sched -fdump-rtl-sms --param sms-min-sc=1" } */
 /* { dg-options "-O2 -fmodulo-sched -fdump-rtl-sms --param sms-min-sc=1 -fmodulo-sched-allow-regmoves" { target powerpc*-*-* } } */
 
+#if (__SIZEOF_INT__ <= 2)
+typedef long int array_type;
+#else
+typedef int array_type;
+#endif
+
 extern void abort (void);
 
 __attribute__ ((noinline))
-void foo (int * __restrict__ a, int * __restrict__ b, int * __restrict__ c)
+void foo (array_type * __restrict__ a, array_type * __restrict__ b, array_type * __restrict__ c)
 {
    int i;
    for(i = 0; i < 100; i+=4)
@@ -17,16 +23,13 @@ 
      }
 }   
 
+array_type a[100], b[100], c[100];
 
-int a[100], b[100], c[100];
 int main()
 {
-#if (__SIZEOF_INT__ <= 2)
   int i;
-  long res;
-#else
-  int i, res;
-#endif  
+  array_type res;
+
   for(i = 0; i < 100; i++)
     {
       b[i] = c[i] = i;
@@ -47,4 +50,3 @@ 
 /* { dg-final { scan-rtl-dump-times "SMS succeeded" 1 "sms" { target spu-*-* } } } */
 /* { dg-final { scan-rtl-dump-times "SMS succeeded" 3 "sms" { target powerpc*-*-* } } } */
 /* { dg-final { cleanup-rtl-dump "sms" } } */
-
Index: gcc/testsuite/gcc.dg/torture/vec-cvt-1.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/vec-cvt-1.c	(revision 207817)
+++ gcc/testsuite/gcc.dg/torture/vec-cvt-1.c	(working copy)
@@ -1,4 +1,6 @@ 
 /* { dg-do run } */
+/* This test is too big for small targets.  */
+/* { dg-require-effective-target size32plus } */
 
 #include <stdlib.h>