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

login
register
mail settings
Submitter Tom de Vries
Date Aug. 19, 2011, 4:28 p.m.
Message ID <4E4E8F29.3060907@codesourcery.com>
Download mbox | patch
Permalink /patch/110695/
State New
Headers show

Comments

Tom de Vries - Aug. 19, 2011, 4:28 p.m.
On 07/17/2011 08:33 PM, Tom de Vries wrote:
> Updated version.
> 
> On 06/08/2011 11:45 AM, Tom de Vries wrote:
>> On 06/08/2011 11:42 AM, Tom de Vries wrote:
>>
>>> I'll send the patch with the testcases in a separate email.
>>
> 

2 extra testcases added.

OK for trunk?

Thanks,
- Tom

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

	PR middle-end/43864
	* gcc.dg/fold-compare-2.c (dg-options): Add -fno-tree-tail-merge.
	* gcc/testsuite/gcc.dg/uninit-pred-2_c.c: Same.
	* gcc.dg/pr43864.c: New test.
	* gcc.dg/pr43864-2.c: Same.
	* gcc.dg/pr43864-3.c: Same.
	* gcc.dg/pr43864-4.c: Same.
Richard Guenther - Aug. 25, 2011, 7:35 a.m.
On Fri, Aug 19, 2011 at 6:28 PM, Tom de Vries <vries@codesourcery.com> wrote:
> On 07/17/2011 08:33 PM, Tom de Vries wrote:
>> Updated version.
>>
>> On 06/08/2011 11:45 AM, Tom de Vries wrote:
>>> On 06/08/2011 11:42 AM, Tom de Vries wrote:
>>>
>>>> I'll send the patch with the testcases in a separate email.
>>>
>>
>
> 2 extra testcases added.
>
> OK for trunk?

Ok.

THanks,
Richard.

> Thanks,
> - Tom
>
> 2011-08-19  Tom de Vries  <tom@codesourcery.com>
>
>        PR middle-end/43864
>        * gcc.dg/fold-compare-2.c (dg-options): Add -fno-tree-tail-merge.
>        * gcc/testsuite/gcc.dg/uninit-pred-2_c.c: Same.
>        * gcc.dg/pr43864.c: New test.
>        * gcc.dg/pr43864-2.c: Same.
>        * gcc.dg/pr43864-3.c: Same.
>        * gcc.dg/pr43864-4.c: Same.
>

Patch

Index: gcc/testsuite/gcc.dg/pr43864-4.c
===================================================================
--- gcc/testsuite/gcc.dg/pr43864-4.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr43864-4.c	(revision 0)
@@ -0,0 +1,28 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-pre" } */
+
+/* Different stmt order.  */
+
+int f(int c, int b, int d)
+{
+  int r, r2, e;
+
+  if (c)
+    {
+      r = b + d;
+      r2 = d - b;
+    }
+  else
+    {
+      r2 = d - b;
+      e = d + b;
+      r = e;
+    }
+
+  return r - r2;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */
+/* { dg-final { scan-tree-dump-times "_.*\\\+.*_" 1 "pre"} } */
+/* { dg-final { scan-tree-dump-times " - " 2 "pre"} } */
+/* { dg-final { cleanup-tree-dump "pre" } } */
Index: gcc/testsuite/gcc.dg/fold-compare-2.c
===================================================================
--- gcc/testsuite/gcc.dg/fold-compare-2.c	(revision 176554)
+++ gcc/testsuite/gcc.dg/fold-compare-2.c	(working copy)
@@ -1,5 +1,5 @@ 
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp" } */
+/* { dg-options "-O2 -fno-tree-tail-merge -fdump-tree-vrp" } */
 
 extern void abort (void);
 
Index: gcc/testsuite/gcc.dg/uninit-pred-2_c.c
===================================================================
--- gcc/testsuite/gcc.dg/uninit-pred-2_c.c	(revision 176554)
+++ gcc/testsuite/gcc.dg/uninit-pred-2_c.c	(working copy)
@@ -1,5 +1,5 @@ 
 /* { dg-do compile } */
-/* { dg-options "-Wuninitialized -O2" } */
+/* { dg-options "-Wuninitialized -O2 -fno-tree-tail-merge" } */
 
 int g;
 void bar (void);
Index: gcc/testsuite/gcc.dg/pr43864.c
===================================================================
--- gcc/testsuite/gcc.dg/pr43864.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr43864.c	(revision 0)
@@ -0,0 +1,35 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-pre" } */
+
+extern void foo (char*, int);
+extern void mysprintf (char *, char *);
+extern void myfree (void *);
+extern int access (char *, int);
+extern int fopen (char *, int);
+
+char *
+hprofStartupp (char *outputFileName, char *ctx)
+{
+  char fileName[1000];
+  int fp;
+  mysprintf (fileName, outputFileName);
+  if (access (fileName, 1) == 0)
+    {
+      myfree (ctx);
+      return 0;
+    }
+
+  fp = fopen (fileName, 0);
+  if (fp == 0)
+    {
+      myfree (ctx);
+      return 0;
+    }
+
+  foo (outputFileName, fp);
+
+  return ctx;
+}
+
+/* { dg-final { scan-tree-dump-times "myfree \\(" 1 "pre"} } */
+/* { dg-final { cleanup-tree-dump "pre" } } */
Index: gcc/testsuite/gcc.dg/pr43864-2.c
===================================================================
--- gcc/testsuite/gcc.dg/pr43864-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr43864-2.c	(revision 0)
@@ -0,0 +1,22 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-pre" } */
+
+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 "pre"} } */
+/* { dg-final { scan-tree-dump-times "_.*\\\+.*_" 1 "pre"} } */
+/* { dg-final { cleanup-tree-dump "pre" } } */
Index: gcc/testsuite/gcc.dg/pr43864-3.c
===================================================================
--- gcc/testsuite/gcc.dg/pr43864-3.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr43864-3.c	(revision 0)
@@ -0,0 +1,23 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-pre" } */
+
+/* Commutative case.  */
+
+int f(int c, int b, int d)
+{
+  int r, e;
+
+  if (c)
+    r = b + d;
+  else
+    {
+      e = d + b;
+      r = e;
+    }
+
+  return r;
+}
+
+/* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */
+/* { dg-final { scan-tree-dump-times "_.*\\\+.*_" 1 "pre"} } */
+/* { dg-final { cleanup-tree-dump "pre" } } */