[PATCH 4/5] IPA-SRA testcases
Richard Guenther
rguenther@suse.de
Thu Aug 6 12:00:00 GMT 2009
On Wed, 5 Aug 2009, Martin Jambor wrote:
> Hi,
>
> this patch contains five new testcases to check that IPA-SRA works
> correctly. It also changes one struct-reorg testcase which apparently
> gets confused by this pass and so I switched it off.
Ok.
Thanks,
Richard.
> Thanks,
>
> Martin
>
>
> 2009-07-09 Martin Jambor <mjambor@suse.cz>
>
> * gcc.dg/struct/wo_prof_escape_arg_to_local.c: Do not run IPA-SRA.
> * gcc.dg/ipa/ipa-sra-1.c: New test.
> * gcc.dg/ipa/ipa-sra-2.c: New test.
> * gcc.dg/ipa/ipa-sra-3.c: New test.
> * gcc.dg/ipa/ipa-sra-4.c: New test.
> * gcc.c-torture/execute/ipa-sra-1.c: New test.
>
>
> Index: mine/gcc/testsuite/gcc.dg/struct/wo_prof_escape_arg_to_local.c
> ===================================================================
> --- mine.orig/gcc/testsuite/gcc.dg/struct/wo_prof_escape_arg_to_local.c
> +++ mine/gcc/testsuite/gcc.dg/struct/wo_prof_escape_arg_to_local.c
> @@ -1,4 +1,4 @@
> -/* { dg-options "-O3 -fno-inline -fipa-type-escape -fdump-ipa-all -fipa-struct-reorg -fwhole-program -combine" } */
> +/* { dg-options "-O3 -fno-inline -fno-ipa-sra -fipa-type-escape -fdump-ipa-all -fipa-struct-reorg -fwhole-program -combine" } */
> /* { dg-do compile } */
> /* { dg-do run } */
>
> Index: mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c
> @@ -0,0 +1,41 @@
> +/* { dg-do run } */
> +/* { dg-options "-O2 -fdump-tree-eipa_sra-details" } */
> +
> +struct bovid
> +{
> + float red;
> + int green;
> + void *blue;
> +};
> +
> +extern int printf (const char *, ...);
> +extern void abort (void);
> +
> +static int
> +__attribute__((noinline))
> +ox (struct bovid cow)
> +{
> + if (cow.green != 6)
> + abort ();
> +
> + printf ("green: %f\nblue: %p\nblue again: %p\n", cow.green,
> + cow.blue, cow.blue);
> + return 0;
> +}
> +
> +int
> +main (int argc, char *argv[])
> +{
> + struct bovid cow;
> +
> + cow.red = 7.4;
> + cow.green = 6;
> + cow.blue = &cow;
> +
> + ox (cow);
> + return 0;
> +}
> +
> +/* { dg-final { scan-tree-dump "About to replace expr cow.green with ISRA" "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump "About to replace expr cow.blue with ISRA" "eipa_sra" } } */
> +/* { dg-final { cleanup-tree-dump "eipa_sra" } } */
> Index: mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-2.c
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-2.c
> @@ -0,0 +1,52 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-eipa_sra-details" } */
> +
> +struct bovid
> +{
> + float red;
> + int green;
> + void *blue;
> +};
> +
> +static int
> +__attribute__((noinline))
> +ox (struct bovid *cow)
> +{
> + cow->red = cow->red + cow->green + cow->green;
> + return 0;
> +}
> +
> +int something;
> +
> +static int
> +__attribute__((noinline))
> +ox_improved (struct bovid *calf)
> +{
> + if (something > 0)
> + calf->red = calf->red + calf->green;
> + else
> + calf->red = calf->green + 87;
> + something = 77;
> + return 0;
> +}
> +
> +
> +int main (int argc, char *argv[])
> +{
> + struct bovid cow;
> +
> + cow.red = 7.4;
> + cow.green = 6;
> + cow.blue = &cow;
> +
> + ox (&cow);
> +
> + ox_improved (&cow);
> + return 0;
> +}
> +
> +/* { dg-final { scan-tree-dump "About to replace expr cow_.*D.->red with \\*ISRA" "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump "About to replace expr cow_.*D.->green with ISRA" "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump "About to replace expr calf_.*D.->red with \\*ISRA" "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump "About to replace expr calf_.*D.->green with ISRA" "eipa_sra" } } */
> +/* { dg-final { cleanup-tree-dump "eipa_sra" } } */
> Index: mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-3.c
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-3.c
> @@ -0,0 +1,39 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-eipa_sra-details" } */
> +
> +struct bovid
> +{
> + float red;
> + int green;
> + void *blue;
> +};
> +
> +extern void foo (float, void *, void *, long);
> +
> +static int
> +__attribute__((noinline))
> +ox (struct bovid cow, int z, struct bovid calf, long l)
> +{
> + foo (cow.red, cow.blue, cow.blue, l);
> + return 0;
> +}
> +
> +void caller (void)
> +{
> + struct bovid cow, calf;
> +
> + cow.red = 7.4;
> + cow.green = 6;
> + cow.blue = &cow;
> +
> + calf.red = 8.4;
> + calf.green = 5;
> + calf.blue = &cow;
> +
> + ox (cow,4,calf,2);
> + return;
> +}
> +
> +/* { dg-final { scan-tree-dump "base: z, remove_param" "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump "base: calf, remove_param" "eipa_sra" } } */
> +/* { dg-final { cleanup-tree-dump "eipa_sra" } } */
> Index: mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-4.c
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-4.c
> @@ -0,0 +1,68 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-eipa_sra-details" } */
> +
> +static int
> +__attribute__((noinline))
> +ox (int *i)
> +{
> + return *i+4**i;
> +}
> +
> +int *holder;
> +
> +static int
> +__attribute__((noinline))
> +ox_ctrl_1 (int *j)
> +{
> + holder = j;
> + return *j+4 * *j+1;
> +}
> +
> +static void
> +__attribute__((noinline))
> +ox_ctrl_2 (int *k)
> +{
> + *k = 8;
> +}
> +
> +static int zzz[10];
> +
> +static int
> +__attribute__((noinline))
> +ox_improved (int recurse, int *l)
> +{
> + int r = 0;
> +
> + r = *l;
> +
> + if (recurse)
> + {
> + if (recurse > 2)
> + l = &zzz[3];
> + else
> + l = zzz;
> +
> + ox_improved (0, l);
> + }
> +
> + return r;
> +}
> +
> +void caller (void)
> +{
> + int a = 1;
> + int b = 10;
> + int c;
> +
> + ox (&a);
> + ox_ctrl_1 (&a);
> + ox_ctrl_2 (&a);
> + *holder = ox_improved (1, &b);
> + return;
> +}
> +
> +/* { dg-final { scan-tree-dump "About to replace expr \\*i_.*D. with ISRA" "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump "About to replace expr \\*l_.*D. with ISRA" "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump-times "About to replace expr \*j_.*D. with ISRA" 0 "eipa_sra" } } */
> +/* { dg-final { scan-tree-dump-times "About to replace expr \*k_.*D. with ISRA" 0 "eipa_sra" } } */
> +/* { dg-final { cleanup-tree-dump "eipa_sra" } } */
> Index: mine/gcc/testsuite/gcc.c-torture/execute/ipa-sra-1.c
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/gcc.c-torture/execute/ipa-sra-1.c
> @@ -0,0 +1,34 @@
> +/* Trivially making sure IPA-SRA does not introduce segfaults where they should
> + not be. */
> +
> +struct bovid
> +{
> + float red;
> + int green;
> + void *blue;
> +};
> +
> +static int
> +__attribute__((noinline))
> +ox (int fail, struct bovid *cow)
> +{
> + int r;
> + if (fail)
> + r = cow->red;
> + else
> + r = 0;
> + return r;
> +}
> +
> +int main (int argc, char *argv[])
> +{
> + struct bovid cow;
> + int r;
> +
> + cow.red = 7.4;
> + cow.green = 6;
> + cow.blue = &cow;
> +
> + r = ox ((argc > 2000), (void *) 0);
> + return r;
> +}
>
>
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex
More information about the Gcc-patches
mailing list