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, pretty-ipa merge 4/4] IPA-SRA testcases


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-06-23  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-early-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"  } */
+
+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,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-eipa_sra"  } */
+
+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 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_.*D.->red with \\*ISRA" "eipa_sra"  } } */
+/* { dg-final { scan-tree-dump "About to replace expr cow_.*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" } */
+
+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" } */
+
+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;
+}


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