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]

Re-organize initial optimization passes


This patch re-organizes the tree optimizers a little bit to give
VRP more opportunities to work with.  It's modelled after the
pipeline as it existed in TCB but without the replication of
CCP/FRE/COPY-PROP that was causing some serious compile time
slowdowns in TCB.

I would very much like to use Ben Elliston's harness on some
selected codes to see if we can do better for various -Ox levels
(hint, hint, Ben).

The new pipeline looks like this:

---------------------------------------------------------------------------
  [ ... ]

  /* Initial scalar cleanups.  */
  NEXT_PASS (pass_ccp);
  NEXT_PASS (pass_fre);
  NEXT_PASS (pass_dce);
  NEXT_PASS (pass_forwprop);
  NEXT_PASS (pass_vrp);
  NEXT_PASS (pass_copy_prop);
  NEXT_PASS (pass_dce);
  NEXT_PASS (pass_dominator);

  [ ... ]
---------------------------------------------------------------------------

Kazu had also gotten good results for VRP with something similar
to this, so these stats will reflect that.  These stats are to be
taken with a grain of salt, though.  The simplistic metric of
counting transformation opportunities is a double edged sword,
but here it goes.

This table describes the increase in number of transformations
for redundancy elimination, constant propagation and range
propagation:
		
		 CCP	  RE	   VRP
-------------------------------------------
cc1-i-files	+25%	+ 3.5%	 +1,947%
DLV		+ 5%	+13.3%	+23,755%
MICO		+.3%	+16.1%	 +3,342%
SPEC2000	+40%	+ 6.6%	    +66%
TRAMP3D		- 6%	+20.8%	   +551%
PR12850		-12%	+15.9%	    +66%
-------------------------------------------

Again, take those numbers with a grain of salt.  The boundaries
between CCP and VRP are sometimes blurry and DOM used to do the
work of both, so what you see is mostly a shifting from DOM into
the other passes.

Despite the new passes, compile times are largely unaffected.  I
noticed two effects: (1) since DOM has less work to do, its times
are down between 11% (DLV) and 35% (PR12850).  (2) Some RTL
passes (alias analysis, CSE and the combiner) are also down a few
percent (less than 10, usually).  Overall, the compile times are
less than 0.8% higher than before.

SPEC is largely unaffected both in x86 and ppc64.  There are some
minor gains in eon, perl and parser.   But nothing worth
mentioning.

The bad news is that our weak uninitialized warning harness
gave me more than a few headaches.  It either misfires causing
bootstrap failures or breaks some uninit tests in the testsuite.
I finally settled for one that breaks one of the uninit tests,
fixes another one and allows us to bootstrap.

This is not a healthy situation, so I am going to re-open one of
the uninitialized warning PRs (PR 18501) and try to fix it for
good.  We need a deterministic uninitialized warning system.  If
it's going to mis-fire, it shouldn't get confused because DCE did
or didn't run at this or that spot.

Bootstrapped and tested x86, ia64, ppc64 and x86-64.


Diego.


	* tree-optimize.c (init_tree_optimization_passes): Re-organize
	optimization passes to do an initial batch of scalar cleanups.

testsuite/ChangeLog

	* gcc.dg/pr18501.c: XFAIL.
	* gcc.dg/tree-ssa/loop-4.c: Fix expected pattern.
	* gcc.dg/tree-ssa/pr20913.c: Change to link-time test.
	* gcc.dg/tree-ssa/ssa-ccp-2.c: Change to a .optimized scan.
	* gcc.dg/tree-ssa/ssa-ccp-7.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ccp-9.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dom-ccp-1.c: Likewise.
	* gcc.dg/tree-ssa/ssa-pre-7.c: Change to a .fre scan.
	* gcc.dg/tree-ssa/ssa-pre-8.c: Likewise.

Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.88
diff -d -u -p -r2.88 tree-optimize.c
--- tree-optimize.c	27 Apr 2005 09:11:00 -0000	2.88
+++ tree-optimize.c	11 May 2005 01:30:19 -0000
@@ -364,12 +364,17 @@ init_tree_optimization_passes (void)
   NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_rename_ssa_copies);
   NEXT_PASS (pass_early_warn_uninitialized);
-  NEXT_PASS (pass_dce);
-  NEXT_PASS (pass_dominator);
-  NEXT_PASS (pass_copy_prop);
+
+  /* Initial scalar cleanups.  */
+  NEXT_PASS (pass_ccp);
+  NEXT_PASS (pass_fre);
   NEXT_PASS (pass_dce);
   NEXT_PASS (pass_forwprop);
   NEXT_PASS (pass_vrp);
+  NEXT_PASS (pass_copy_prop);
+  NEXT_PASS (pass_dce);
+  NEXT_PASS (pass_dominator);
+
   NEXT_PASS (pass_merge_phi);
   NEXT_PASS (pass_phiopt);
   NEXT_PASS (pass_may_alias);
@@ -403,6 +408,7 @@ init_tree_optimization_passes (void)
   NEXT_PASS (pass_loop);
   NEXT_PASS (pass_dominator);
   NEXT_PASS (pass_copy_prop);
+  NEXT_PASS (pass_dce);
   /* FIXME: If DCE is not run before checking for uninitialized uses,
      we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
      However, this also causes us to misdiagnose cases that should be
Index: testsuite/gcc.dg/pr18501.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/pr18501.c,v
retrieving revision 1.1
diff -d -u -p -r1.1 pr18501.c
--- testsuite/gcc.dg/pr18501.c	17 Dec 2004 22:20:33 -0000	1.1
+++ testsuite/gcc.dg/pr18501.c	11 May 2005 01:30:22 -0000
@@ -9,7 +9,7 @@ int something (void);
 void
 bitmap_print_value_set (void)
 {
-  unsigned first;	/* { dg-warning "may be used" "conditional in loop" } */
+  unsigned first;	/* { dg-warning "may be used" "conditional in loop" { xfail *-*-* } } */
   
   for (; bmp_iter_set (); )
     {
Index: testsuite/gcc.dg/tree-ssa/loop-4.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c,v
retrieving revision 1.4
diff -d -u -p -r1.4 loop-4.c
--- testsuite/gcc.dg/tree-ssa/loop-4.c	31 Mar 2005 18:34:15 -0000	1.4
+++ testsuite/gcc.dg/tree-ssa/loop-4.c	11 May 2005 01:30:22 -0000
@@ -32,9 +32,9 @@ void xxx(void)
    -- induction variable with base 0, the memory access of form
       *(iv + &arr_base[0].y) = ...
 
-   In any case, we should not have 'arr_base.[^0].* ='  */
+   In any case, we should not have 'arr_base[.*] ='  */
 
-/* { dg-final { scan-tree-dump-times "arr_base.\[^0\]\[^\\n\\r\]*=" 0 "vars" } } */
+/* { dg-final { scan-tree-dump-times "arr_base\[.*\]\.y =" 0 "vars" } } */
 
 /* And the original induction variable should be eliminated.  */
 
Index: testsuite/gcc.dg/tree-ssa/pr20913.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr20913.c,v
retrieving revision 1.2
diff -d -u -p -r1.2 pr20913.c
--- testsuite/gcc.dg/tree-ssa/pr20913.c	28 Apr 2005 16:38:13 -0000	1.2
+++ testsuite/gcc.dg/tree-ssa/pr20913.c	11 May 2005 01:30:22 -0000
@@ -2,8 +2,8 @@
    COPY-PROP did not fold COND_EXPR, blocking some copy propagation
    opportunities.  */
 
-/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-copyprop1-details" } */
+/* { dg-do link } */
+/* { dg-options "-O2 -fno-tree-dominator-opts" } */
 
 int
 foo (int a, int b, int c, int d)
@@ -14,13 +14,21 @@ foo (int a, int b, int c, int d)
   if (a == b)
     x = c;
   else
-    x = d;
+    {
+      link_error ();
+      x = d;
+    }
 
   if (x == c)
     return a;
   else
-    return b;
+    {
+      link_error ();
+      return b;
+    }
 }
 
-/* { dg-final { scan-tree-dump-times "with if \\(1\\)" 2 "copyprop1"} } */
-/* { dg-final { cleanup-tree-dump "copyprop1" } } */
+main()
+{
+  foo (1, 2, 3, 4);
+}
Index: testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c,v
retrieving revision 1.5
diff -d -u -p -r1.5 ssa-ccp-2.c
--- testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c	10 May 2005 00:57:28 -0000	1.5
+++ testsuite/gcc.dg/tree-ssa/ssa-ccp-2.c	11 May 2005 01:30:22 -0000
@@ -1,5 +1,5 @@
 /* { dg-do compile } */ 
-/* { dg-options "-O2 -fdump-tree-store_ccp" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
 
 extern void link_error (void);
 
@@ -168,5 +168,5 @@ int test99999 (void)
 
 /* There should be not link_error calls, if there is any the
    optimization has failed */
-/* { dg-final { scan-tree-dump-times "link_error" 0 "store_ccp"} } */
-/* { dg-final { cleanup-tree-dump "store_ccp" } } */
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: testsuite/gcc.dg/tree-ssa/ssa-ccp-7.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-7.c,v
retrieving revision 1.5
diff -d -u -p -r1.5 ssa-ccp-7.c
--- testsuite/gcc.dg/tree-ssa/ssa-ccp-7.c	10 May 2005 00:57:28 -0000	1.5
+++ testsuite/gcc.dg/tree-ssa/ssa-ccp-7.c	11 May 2005 01:30:22 -0000
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-store_ccp" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
 
 extern void link_error (void);
 
@@ -23,5 +23,5 @@ int test7 (int a)
 
 /* There should be not link_error calls, if there is any the
    optimization has failed */
-/* { dg-final { scan-tree-dump-times "link_error" 0 "store_ccp"} } */
-/* { dg-final { cleanup-tree-dump "store_ccp" } } */
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: testsuite/gcc.dg/tree-ssa/ssa-ccp-9.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-9.c,v
retrieving revision 1.5
diff -d -u -p -r1.5 ssa-ccp-9.c
--- testsuite/gcc.dg/tree-ssa/ssa-ccp-9.c	10 May 2005 00:57:28 -0000	1.5
+++ testsuite/gcc.dg/tree-ssa/ssa-ccp-9.c	11 May 2005 01:30:22 -0000
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-store_ccp" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
 
 /* Check that cprop works for assignments to array elements and structs.  */
 
@@ -51,5 +51,5 @@ test99999 (int *arr, int j)
 
 /* There should be no link_error calls, if there is any, the
    optimization has failed */
-/* { dg-final { scan-tree-dump-times "link_error" 0 "store_ccp"} } */
-/* { dg-final { cleanup-tree-dump "store_ccp" } } */
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: testsuite/gcc.dg/tree-ssa/ssa-dom-ccp-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-ccp-1.c,v
retrieving revision 1.3
diff -d -u -p -r1.3 ssa-dom-ccp-1.c
--- testsuite/gcc.dg/tree-ssa/ssa-dom-ccp-1.c	31 Mar 2005 18:34:16 -0000	1.3
+++ testsuite/gcc.dg/tree-ssa/ssa-dom-ccp-1.c	11 May 2005 01:30:22 -0000
@@ -1,5 +1,5 @@
 /* { dg-do compile } */ 
-/* { dg-options "-O2 -fdump-tree-dom1-details" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
 int t(int a) __attribute__ ((const));
 void abort (void);
 int
@@ -14,5 +14,5 @@ ccp(int b)
 	return a;
 }
 /* We should propagate constant 4 into return.  */
-/* { dg-final { scan-tree-dump-times "Replaced.*with constant '4'" 1 "dom1"} } */
-/* { dg-final { cleanup-tree-dump "dom1" } } */
+/* { dg-final { scan-tree-dump-times "return 4" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: testsuite/gcc.dg/tree-ssa/ssa-pre-7.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-7.c,v
retrieving revision 1.1
diff -d -u -p -r1.1 ssa-pre-7.c
--- testsuite/gcc.dg/tree-ssa/ssa-pre-7.c	4 Apr 2005 19:02:15 -0000	1.1
+++ testsuite/gcc.dg/tree-ssa/ssa-pre-7.c	11 May 2005 01:30:22 -0000
@@ -1,5 +1,5 @@
 /* { dg-do compile } */ 
-/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-pre-stats" } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-fre-stats" } */
 int
 foo (int *array)
 {
@@ -8,5 +8,5 @@ foo (int *array)
       return 0;
 }
 /* We should eliminate one address calculation, and one load.  */
-/* { dg-final { scan-tree-dump-times "Eliminated: 2" 1 "pre"} } */
-/* { dg-final { cleanup-tree-dump "pre" } } */
+/* { dg-final { scan-tree-dump-times "Eliminated: 2" 1 "fre"} } */
+/* { dg-final { cleanup-tree-dump "fre" } } */
Index: testsuite/gcc.dg/tree-ssa/ssa-pre-8.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-8.c,v
retrieving revision 1.2
diff -d -u -p -r1.2 ssa-pre-8.c
--- testsuite/gcc.dg/tree-ssa/ssa-pre-8.c	5 Apr 2005 22:28:01 -0000	1.2
+++ testsuite/gcc.dg/tree-ssa/ssa-pre-8.c	11 May 2005 01:30:22 -0000
@@ -1,5 +1,5 @@
 /* { dg-do compile } */ 
-/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-pre-stats" } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-fre-stats" } */
 struct s {
       int *n;
 };
@@ -17,5 +17,5 @@ foo (__SIZE_TYPE__ i, struct s *array)
   return 0;
 }
 /* We should eliminate two address calculations, one cast, and one load.  */
-/* { dg-final { scan-tree-dump-times "Eliminated: 4" 1 "pre"} } */
-/* { dg-final { cleanup-tree-dump "pre" } } */
+/* { dg-final { scan-tree-dump-times "Eliminated: 4" 1 "fre"} } */
+/* { dg-final { cleanup-tree-dump "fre" } } */


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