This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 4/5] IPA-SRA testcases
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Richard Guenther <rguenther at suse dot de>
- Date: Wed, 05 Aug 2009 17:21:32 +0200
- Subject: [PATCH 4/5] IPA-SRA testcases
- References: <20090805152128.023505229@virgil.suse.cz>
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.
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;
+}