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]

Re: [PATCH 3/3] Testcase changes for the new SRA


On Tue, 26 May 2009, Martin Jambor wrote:

> The following patch amends testcases (rather than the compiler) so
> that they not fail with the new intra-SRA.
> 
> The FRE testcases rely on the fact that SRA does not scalarize unions.
> The new one,  however, does.  Therefore I simply  switched SRA off for
> them (and Richi approved this change anlready).
> 
> The gfortran.dg/pr25923.f90 expects a weird warning that I do not give
> out because the new SRA does not scalarize anything in that particular
> testcase  because the  individual fields  of the  structure  are never
> accessed on their  own.  I have XFAILed the  warning test as requested
> (http://gcc.gnu.org/ml/gcc-patches/2009-04/msg02237.html).
> 
> A few testcases used the removed parameters so I made them not to.
> 
> I have added a few testcases of my own, mainly to test that unions get
> scalarized  too but  also  that "subaccesses"  are propagated  accross
> assignments.
> 
> With this patch, there are  no regressions (not counting the xfail) in
> the testsuite on  x86_64-linux-gnu (inluding Ada) and i586-suse-linux.
> The  patch has  bootstrapped  on hppa-linux-gnu  but  tests are  still
> running.


> Index: mine/gcc/testsuite/gcc.dg/tree-ssa/sra-1.c
> ===================================================================
> --- mine.orig/gcc/testsuite/gcc.dg/tree-ssa/sra-1.c
> +++ mine/gcc/testsuite/gcc.dg/tree-ssa/sra-1.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */ 
> -/* { dg-options "-O1 -fdump-tree-optimized --param sra-max-structure-size=32" } */
> +/* { dg-options "-O1 -fdump-tree-optimized" } */
>  
>  /* Tests for SRA. */
>  
> @@ -68,6 +68,73 @@ copystruct111111 (teststruct param)
>      link_error ();
>  }
>  
> +
> +typedef union testunion
> +{
> +  double d;
> +  char f1;
> +} testunion;
> +
> +void
> +copyunion1 (testunion param)
> +{
> +  testunion local;
> +  param.f1 = 0;
> +  local = param;
> +  if (local.f1 != 0)
> +    link_error ();
> +}
> +
> +void
> +copyunion11 (testunion *param)
> +{
> +  testunion local;
> +  param->f1 = 0;
> +  local = *param;
> +  if (local.f1 != 0)
> +    link_error ();
> +}
> +
> +void
> +copyunion111 (testunion param)
> +{
> +  testunion *local = &param;
> +  param.f1 = 0;
> +  if (local->f1 != 0)
> +    link_error ();
> +}
> +
> +testunion globuf;
> +void
> +copyunion1111 (void)
> +{
> +  testunion local;
> +  globuf.f1 = 0;
> +  local = globuf;
> +  if (local.f1 != 0)
> +    link_error ();
> +}
> +
> +void
> +copyunion11111 (void)
> +{
> +  testunion *local = &globuf;
> +  globuf.f1 = 0;
> +  if (local->f1 != 0)
> +    link_error ();
> +}
> +
> +void
> +copyunion111111 (testunion param)
> +{
> +  static testunion local;
> +  param.f1 = 0;
> +  local = param;
> +  if (local.f1 != 0)
> +    link_error ();
> +}
> +
> +
>  /* There should be no referenc to link_error. */
>  /* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
>  /* { dg-final { cleanup-tree-dump "optimized" } } */

Can you put these into a new testcase instead of amending the existing
one?

> Index: mine/gcc/testsuite/gcc.dg/tree-ssa/sra-5.c
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gcc.dg/tree-ssa/sra-5.c
> @@ -0,0 +1,75 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1" } */
> +/* Let gimple verifier check what SRA does to unions and single-field
> +   strucutres . */
> +
> +struct sim_struct
> +{
> +  int x;
> +};
> +
> +extern struct sim_struct get_x(void);
> +
> +struct sim_struct foo (void)
> +{
> +  struct sim_struct simple;
> +
> +  simple = get_x ();
> +  if (simple.x % 2)
> +    simple.x = 39;
> +  else
> +    simple.x -=8;
> +
> +  return simple;
> +}
> +
> +struct sim_cmplx
> +{
> +  _Complex double c;
> +};
> +
> +extern struct sim_cmplx get_sc (void);
> +
> +_Complex double foo_c (void)
> +{
> +  struct sim_cmplx simple;
> +
> +  simple = get_sc ();
> +  if (__real__ simple.c > 200.3)
> +    __imag__ simple.c -= 2.4;
> +
> +  return simple.c;
> +}
> +
> +
> +union sim_union
> +{
> +  int i;
> +  float d;
> +};
> +
> +extern union sim_union get_y (void);
> +
> +union sim_union bar (void)
> +{
> +  union sim_union simple;
> +
> +  simple = get_y ();
> +  if (simple.d > 8.2)
> +    simple.i = 300;
> +
> +  return simple;
> +}
> +
> +extern int get_int (void);
> +
> +int bar_i (void)
> +{
> +  union sim_union simple;
> +
> +  simple = get_y ();
> +  if (simple.d > 8.2)
> +    simple.i = get_int ();
> +
> +  return simple.i;
> +}

If it is only a gimple validity check the testcase should go
to gcc.c-torture/compile, if not then please add some
dump scanning to verify the correct stuff is done.


> Index: mine/gcc/testsuite/gcc.dg/tree-ssa/sra-6.c
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gcc.dg/tree-ssa/sra-6.c
> @@ -0,0 +1,40 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1 -fdump-tree-optimized -fdump-tree-esra-details" } */
> +
> +typedef struct teststruct
> +{
> +  double d;
> +  int i1;
> +  char c1;
> +  float z;
> +  char c2;
> +  int i2;
> +} teststruct;
> +
> +
> +void cow (int i)
> +{
> +  teststruct a, b, c, d;
> +
> +  a.d = 3.2;
> +  a.i1 = i;
> +
> +  b = a;
> +  c = b;
> +  d = c;
> +
> +  if (d.i1 != i)
> +    link_error ();
> +}
> +
> +
> +/* Suaccesses of b and c should have been created.  */
> +/* { dg-final { scan-tree-dump "expr = b.d"  "esra"} } */
> +/* { dg-final { scan-tree-dump "expr = b.i1"  "esra"} } */
> +/* { dg-final { scan-tree-dump "expr = c.d"  "esra"} } */
> +/* { dg-final { scan-tree-dump "expr = c.i1"  "esra"} } */
> +/* { dg-final { cleanup-tree-dump "esra" } } */
> +
> +/* There should be no referenc to link_error.  */

reference

> +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
> +/* { dg-final { cleanup-tree-dump "optimized" } } */


Ok with these changes.

Richard.


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