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: [PATCH] Fix code quality regression on UltraSPARC


> So not only do we get to remove that loop, the current condition
> can be simplified to just "e = EDGE_PRED (dummy, 0);", i.e. pick
> an arbitrary preheader predecessor.

Revised patch with revised timings.  Bootstrapped/regtested on 
amd64-mandrake-linux-gnu.

32-bit:
./gzip33 gcc.tar  29.68s user 0.65s system 98% cpu 30.881 total
./gzip33 gcc.tar  29.44s user 0.84s system 98% cpu 30.626 total
./gzip33 gcc.tar  29.58s user 0.63s system 98% cpu 30.599 total

./gzip34 gcc.tar  24.81s user 0.55s system 97% cpu 25.881 total
./gzip34 gcc.tar  24.83s user 0.55s system 98% cpu 25.836 total
./gzip34 gcc.tar  24.64s user 0.72s system 98% cpu 25.760 total

./gzip40 gcc.tar  24.94s user 0.74s system 98% cpu 26.041 total
./gzip40 gcc.tar  25.15s user 0.56s system 98% cpu 26.139 total
./gzip40 gcc.tar  25.29s user 0.41s system 98% cpu 26.198 total

./gzip40.1 gcc.tar  24.15s user 0.86s system 96% cpu 25.989 total
./gzip40.1 gcc.tar  24.29s user 0.62s system 98% cpu 25.356 total
./gzip40.1 gcc.tar  24.23s user 0.62s system 98% cpu 25.232 total


64-bit:
./gzip33 gcc.tar  34.14s user 0.82s system 99% cpu 35.194 total
./gzip33 gcc.tar  34.11s user 0.76s system 99% cpu 35.009 total
./gzip33 gcc.tar  34.08s user 0.69s system 99% cpu 34.901 total

./gzip34 gcc.tar  29.19s user 0.63s system 99% cpu 29.983 total
./gzip34 gcc.tar  29.03s user 0.75s system 99% cpu 29.941 total
./gzip34 gcc.tar  29.15s user 0.62s system 99% cpu 29.886 total

./gzip40 gcc.tar  31.07s user 0.65s system 99% cpu 31.874 total
./gzip40 gcc.tar  31.19s user 0.59s system 99% cpu 31.905 total
./gzip40 gcc.tar  31.25s user 0.56s system 99% cpu 31.924 total

./gzip40.1 gcc.tar  27.07s user 0.87s system 99% cpu 28.188 total
./gzip40.1 gcc.tar  27.00s user 0.66s system 99% cpu 27.734 total
./gzip40.1 gcc.tar  26.97s user 0.70s system 99% cpu 27.761 total



2004-12-16  Eric Botcazou  <ebotcazou@libertysurf.fr>
              Roger Sayle  <roger@eyesopen.com>
 
	PR tree-optimization/18707
	* cfgloopmanip.c (create_preheader): Move the preheader
	only if the latch was falling through to the header.


-- 
Eric Botcazou
Index: cfgloopmanip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopmanip.c,v
retrieving revision 1.39
diff -u -p -r1.39 cfgloopmanip.c
--- cfgloopmanip.c	8 Dec 2004 18:52:48 -0000	1.39
+++ cfgloopmanip.c	16 Dec 2004 14:21:19 -0000
@@ -1142,6 +1142,8 @@ create_preheader (struct loop *loop, int
   struct loop *cloop, *ploop;
   int nentry = 0;
   bool irred = false;
+  bool latch_edge_was_fallthru;
+  edge one_succ_pred = 0;
   edge_iterator ei;
 
   cloop = loop->outer;
@@ -1152,6 +1154,8 @@ create_preheader (struct loop *loop, int
 	continue;
       irred |= (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0;
       nentry++;
+      if (EDGE_COUNT (e->src->succs) == 1)
+	one_succ_pred = e;
     }
   gcc_assert (nentry);
   if (nentry == 1)
@@ -1166,6 +1170,7 @@ create_preheader (struct loop *loop, int
     }
 
   mfb_kj_edge = loop_latch_edge (loop);
+  latch_edge_was_fallthru = (mfb_kj_edge->flags & EDGE_FALLTHRU) != 0;
   fallthru = make_forwarder_block (loop->header, mfb_keep_just,
 				   mfb_update_loops);
   dummy = fallthru->src;
@@ -1177,13 +1182,23 @@ create_preheader (struct loop *loop, int
     if (ploop->latch == dummy)
       ploop->latch = fallthru->dest;
 
-  /* Reorganize blocks so that the preheader is not stuck in the middle of the
-     loop.  */
-  
-  /* Get an edge that is different from the one from loop->latch to
-     dummy.  */
-  e = EDGE_PRED (dummy, EDGE_PRED (dummy, 0)->src == loop->latch);
-  move_block_after (dummy, e->src);
+  /* Try to be clever in placing the newly created preheader.  The idea is to
+     avoid breaking any "fallthruness" relationship between blocks.
+
+     The preheader was created just before the header and all incoming edges
+     to the header were redirected to the preheader, except the latch edge.
+     So the only problematic case is when this latch edge was a fallthru
+     edge: it is not anymore after the preheader creation so we have broken
+     the fallthruness.  We're therefore going to look for a better place.  */
+  if (latch_edge_was_fallthru)
+    {
+      if (one_succ_pred)
+	e = one_succ_pred;
+      else
+	e = EDGE_PRED (dummy, 0);
+
+      move_block_after (dummy, e->src);
+    }
 
   loop->header->loop_father = loop;
   add_bb_to_loop (dummy, cloop);

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