Patchwork [PR43864] Gimple level duplicate block cleanup - test cases.

login
register
mail settings
Submitter Tom de Vries
Date June 8, 2011, 9:45 a.m.
Message ID <4DEF44C1.4070800@codesourcery.com>
Download mbox | patch
Permalink /patch/99388/
State New
Headers show

Comments

Tom de Vries - June 8, 2011, 9:45 a.m.
On 06/08/2011 11:42 AM, Tom de Vries wrote:

> I'll send the patch with the testcases in a separate email.

OK for trunk?

Thanks,
- Tom

2011-06-08  Tom de Vries  <tom@codesourcery.com>

	PR middle-end/43864
	* gcc.dg/pr43864.c: New test.
	* gcc.dg/pr43864-2.c: New test.

Patch

Index: gcc/testsuite/gcc.dg/pr43864-2.c
===================================================================
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/pr43864-2.c (revision 0)
@@ -0,0 +1,22 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int f(int c, int b, int d)
+{
+  int r, e;
+
+  if (c)
+    r = b + d;
+  else
+    {
+      e = b + d;
+      r = e;
+    }
+
+  return r;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 0 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "\\\+" 1 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "PHI" 0 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: gcc/testsuite/gcc.dg/pr43864.c
===================================================================
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/pr43864.c (revision 0)
@@ -0,0 +1,33 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void foo (char*, FILE*);
+
+char* hprofStartupp (char *outputFileName, char *ctx)
+{
+  char fileName[1000];
+  FILE *fp;
+  sprintf (fileName, outputFileName);
+  if (access (fileName, 1) == 0)
+    {
+      free (ctx);
+      return 0;
+    }
+
+  fp = fopen (fileName, 0);
+  if (fp == 0)
+    {
+      free (ctx);
+      return 0;
+    }
+
+  foo (outputFileName, fp);
+
+  return ctx;
+}
+
+/* { dg-final { scan-tree-dump-times "free" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */