DOM profile updating bug...

Jan Hubicka jh@suse.cz
Mon Aug 1 17:31:00 GMT 2005


Hi,
it turns out that when dominator opts decide to thread edge, the
tree-ssa-threadupdate might take the decision back to avoid constructing of
irregular region in loop.  This causes profile to be updated as if the edge was
threaded but CFG be kept in original form.  This has particularly nasty side
effect of decreasing number of iterations of loop usually bellow 0 bypassing
any attempts for unrolling and such.

With some experimentation I think I found place where all the edges are already
set down but no transformations performed yet.  I am still regtesting the patch.
Jeff, does this seem to make sense to you?

Note that the testcase needs another fix into complette unrolling I am testing
now too to pass, but the missmatches after dom2 pass should go away and
new ones should appear in cunroll.

Honza

2005-08-01  Jan Hubicka  <jh@suse.cz>
	* tree-ssa-dom.c (thread_across_edge): Remove updating here.
	(thread_block): Add it here.
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.126
diff -c -3 -p -r2.126 tree-ssa-dom.c
*** tree-ssa-dom.c	29 Jul 2005 14:41:53 -0000	2.126
--- tree-ssa-dom.c	1 Aug 2005 17:25:51 -0000
*************** thread_across_edge (struct dom_walk_data
*** 848,855 ****
  	    {
  	      struct edge_info *edge_info;
  
- 	      update_bb_profile_for_threading (e->dest, EDGE_FREQUENCY (e),
- 					       e->count, taken_edge);
  	      if (e->aux)
  		edge_info = e->aux;
  	      else
--- 848,853 ----
Index: tree-ssa-threadupdate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-threadupdate.c,v
retrieving revision 2.32
diff -c -3 -p -r2.32 tree-ssa-threadupdate.c
*** tree-ssa-threadupdate.c	15 Jul 2005 09:46:17 -0000	2.32
--- tree-ssa-threadupdate.c	1 Aug 2005 17:25:51 -0000
*************** thread_block (basic_block bb)
*** 724,729 ****
--- 724,731 ----
        else
  	{
  	  edge e2 = e->aux;
+ 	  update_bb_profile_for_threading (e->dest, EDGE_FREQUENCY (e),
+ 					   e->count, e->aux);
  
  	  /* If we thread to a loop exit edge, then we will need to 
  	     rediscover the loop exit edges.  While it may seem that
Index: testsuite/gcc.dg/tree-ssa/update-threading.c
===================================================================
RCS file: testsuite/gcc.dg/tree-ssa/update-threading.c
diff -N testsuite/gcc.dg/tree-ssa/update-threading.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/tree-ssa/update-threading.c	1 Aug 2005 17:25:58 -0000
***************
*** 0 ****
--- 1,24 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -fdump-tree-optimized" } */
+ 
+ typedef struct { unsigned short a; } A;
+ 
+ extern void abort (void);
+ extern void exit (int);
+ 
+ void foo (unsigned int x)
+ {
+   if (x != 0x800 && x != 0x810)
+     abort ();
+ }
+ 
+ int
+ main (int argc, char **argv)
+ {
+   int i;
+   for (i = 0; i < 2; ++i)
+     foo (((A) { ((!(i >> 4) ? 8 : 64 + (i >> 4)) << 8) + (i << 4) } ).a);
+   exit (0);
+ }
+ /* { dg-final { scan-tree-dump-times ".optimized" 0 "Invalid sum"} } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */



More information about the Gcc-patches mailing list