This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH,testsuite] fix tree-ssa tests that depend on argc


Two tree-ssa tests depend on the value of argc that main receives.
Since argc is not well-defined for some bare-metal targets, this
dependence produces spurious testsuite failures.  The particular failure
mode on gen-vect-25.c was that argc had the value of 0x80000000.  The
compiler vectorized:

int main_1 (int n, int *p)
{
  int i;
  half_word ia[N];

  for (i = 0; i < N; i++)
    {
      ia[i] = n;
    }

correctly (where n = argc), but then failed in the checking code:

  /* check results:  */
  for (i = 0; i < N; i++)
    {
      if (ia[i] != n)
        abort ();
    }

since 0x0 != 0x80000000.  The failure mode on gen-vect-28.c is similar.

The patch below fixes that by using a volatile int where appropriate
instead of an incoming value of argc.

Tested on arm-none-linux-gnueabi and mips-sde-elf (QEMU) with no
regressions.  OK to commit?

-Nathan

2009-06-30  Nathan Froyd  <froydnj@codesourcery.com>

	* gcc.dg/tree-ssa/gen-vect-25.c (n): New variable.
	(main): Change argument name to argc and pass n to main_1 instead.
	* gcc.dg/tree-ssa/gen-vect-28.c (off): New variable.
	(main_1): New function, split off from...
	(main): ...here.  Change argument name to argc and pass off to
	main_1 instead.

Index: gcc.dg/tree-ssa/gen-vect-25.c
===================================================================
--- gcc.dg/tree-ssa/gen-vect-25.c	(revision 149095)
+++ gcc.dg/tree-ssa/gen-vect-25.c	(working copy)
@@ -47,9 +47,11 @@ int main_1 (int n, int *p)
   return 0;
 }
 
-int main (int n)
+static volatile int n = 1;
+
+int main (int argc)
 {
-  return main_1 (n + 2, &n);
+  return main_1 (n + 2, (int *) &n);
 }
 
 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
Index: gcc.dg/tree-ssa/gen-vect-28.c
===================================================================
--- gcc.dg/tree-ssa/gen-vect-28.c	(revision 149095)
+++ gcc.dg/tree-ssa/gen-vect-28.c	(working copy)
@@ -9,7 +9,7 @@
 
 /* unaligned store.  */
 
-int main (int off)
+int main_1 (int off)
 {
   int i;
   char ia[N+OFF];
@@ -29,6 +29,13 @@ int main (int off)
   return 0;
 }
 
+static volatile int off = 1;
+
+int main (int argc)
+{
+  return main_1 (off);
+}
+
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } } */
 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]