public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][RFC] Fix PR63155
@ 2015-03-06 13:16 Richard Biener
  2015-03-06 17:02 ` Jeff Law
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Biener @ 2015-03-06 13:16 UTC (permalink / raw)
  To: gcc-patches


This fixes PR63155 and reduces the memory usage at -O0 from reported
10GB (couldn't verify/update on my small box) to 350MB (still worse
compared to 4.8 which needs only 50MB).

It fixes this by no longer computing live info or building a conflict
graph for coalescing of SSA names flowing over abnormal edges
(which needs to succeed).

Of course this also removes verification that this coalescing is valid
(but computing this has quadratic cost).  With this it turns
ICEs into miscompiles.

We could restrict verifying that we can perform abnormal coalescing
to ENABLE_CHECKING (and I've wanted a verifier pass that can verify
this multiple times to be able to catch what breaks it and not having
to work back from out-of-SSA ICEing...).

So any opinion on this patch welcome.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Ok for trunk? ;)

Thanks,
Richard.

2015-03-06  Richard Biener  <rguenther@suse.de>

	PR middle-end/63155
	* tree-ssa-coalesce.c (attempt_coalesce): Handle graph being NULL.
	(coalesce_partitions): Split out abnormal coalescing to ...
	(perform_abnormal_coalescing): ... this function.
	(coalesce_ssa_name): Perform abnormal coalescing without computing
	live/conflict.

Index: gcc/tree-ssa-coalesce.c
===================================================================
*** gcc/tree-ssa-coalesce.c	(revision 221237)
--- gcc/tree-ssa-coalesce.c	(working copy)
*************** create_outofssa_var_map (coalesce_list_p
*** 1121,1128 ****
  
  
  /* Attempt to coalesce ssa versions X and Y together using the partition
!    mapping in MAP and checking conflicts in GRAPH.  Output any debug info to
!    DEBUG, if it is nun-NULL.  */
  
  static inline bool
  attempt_coalesce (var_map map, ssa_conflicts_p graph, int x, int y,
--- 1121,1128 ----
  
  
  /* Attempt to coalesce ssa versions X and Y together using the partition
!    mapping in MAP and checking conflicts in GRAPH if not NULL.
!    Output any debug info to DEBUG, if it is nun-NULL.  */
  
  static inline bool
  attempt_coalesce (var_map map, ssa_conflicts_p graph, int x, int y,
*************** attempt_coalesce (var_map map, ssa_confl
*** 1154,1160 ****
      fprintf (debug, " [map: %d, %d] ", p1, p2);
  
  
!   if (!ssa_conflicts_test_p (graph, p1, p2))
      {
        var1 = partition_to_var (map, p1);
        var2 = partition_to_var (map, p2);
--- 1154,1161 ----
      fprintf (debug, " [map: %d, %d] ", p1, p2);
  
  
!   if (!graph
!       || !ssa_conflicts_test_p (graph, p1, p2))
      {
        var1 = partition_to_var (map, p1);
        var2 = partition_to_var (map, p2);
*************** attempt_coalesce (var_map map, ssa_confl
*** 1168,1177 ****
  
        /* z is the new combined partition.  Remove the other partition from
  	 the list, and merge the conflicts.  */
!       if (z == p1)
! 	ssa_conflicts_merge (graph, p1, p2);
!       else
! 	ssa_conflicts_merge (graph, p2, p1);
  
        if (debug)
  	fprintf (debug, ": Success -> %d\n", z);
--- 1169,1181 ----
  
        /* z is the new combined partition.  Remove the other partition from
  	 the list, and merge the conflicts.  */
!       if (graph)
! 	{
! 	  if (z == p1)
! 	    ssa_conflicts_merge (graph, p1, p2);
! 	  else
! 	    ssa_conflicts_merge (graph, p2, p1);
! 	}
  
        if (debug)
  	fprintf (debug, ": Success -> %d\n", z);
*************** attempt_coalesce (var_map map, ssa_confl
*** 1185,1208 ****
  }
  
  
! /* Attempt to Coalesce partitions in MAP which occur in the list CL using
!    GRAPH.  Debug output is sent to DEBUG if it is non-NULL.  */
  
  static void
! coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
! 		     FILE *debug)
  {
-   int x = 0, y = 0;
-   tree var1, var2;
-   int cost;
    basic_block bb;
    edge e;
    edge_iterator ei;
  
-   /* First, coalesce all the copies across abnormal edges.  These are not placed
-      in the coalesce list because they do not need to be sorted, and simply
-      consume extra memory/compilation time in large programs.  */
- 
    FOR_EACH_BB_FN (bb, cfun)
      {
        FOR_EACH_EDGE (e, ei, bb->preds)
--- 1189,1204 ----
  }
  
  
! /* Perform all abnormal coalescing on MAP.
!    Debug output is sent to DEBUG if it is non-NULL.  */
  
  static void
! perform_abnormal_coalescing (var_map map, FILE *debug)
  {
    basic_block bb;
    edge e;
    edge_iterator ei;
  
    FOR_EACH_BB_FN (bb, cfun)
      {
        FOR_EACH_EDGE (e, ei, bb->preds)
*************** coalesce_partitions (var_map map, ssa_co
*** 1226,1236 ****
  		if (debug)
  		  fprintf (debug, "Abnormal coalesce: ");
  
! 		if (!attempt_coalesce (map, graph, v1, v2, debug))
  		  fail_abnormal_edge_coalesce (v1, v2);
  	      }
  	  }
      }
  
    /* Now process the items in the coalesce list.  */
  
--- 1222,1244 ----
  		if (debug)
  		  fprintf (debug, "Abnormal coalesce: ");
  
! 		if (!attempt_coalesce (map, NULL, v1, v2, debug))
  		  fail_abnormal_edge_coalesce (v1, v2);
  	      }
  	  }
      }
+ }
+ 
+ /* Attempt to Coalesce partitions in MAP which occur in the list CL using
+    GRAPH.  Debug output is sent to DEBUG if it is non-NULL.  */
+ 
+ static void
+ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
+ 		     FILE *debug)
+ {
+   int x = 0, y = 0;
+   tree var1, var2;
+   int cost;
  
    /* Now process the items in the coalesce list.  */
  
*************** coalesce_ssa_name (void)
*** 1341,1346 ****
--- 1349,1363 ----
        return map;
      }
  
+   /* First, coalesce all the copies across abnormal edges.  These are not placed
+      in the coalesce list because they do not need to be sorted, and simply
+      consume extra memory/compilation time in large programs.
+      Performing abnormal coalescing also needs no live/conflict computation
+      because it must succeed (but we lose checking that it indeed does).
+      Still for PR63155 this reduces memory usage from 10GB to zero.  */
+   perform_abnormal_coalescing (map,
+ 			       ((dump_flags & TDF_DETAILS) ? dump_file : NULL));
+ 
    if (dump_file && (dump_flags & TDF_DETAILS))
      dump_var_map (dump_file, map);
  
*************** coalesce_ssa_name (void)
*** 1371,1378 ****
  
    /* Now coalesce everything in the list.  */
    coalesce_partitions (map, graph, cl,
! 		       ((dump_flags & TDF_DETAILS) ? dump_file
! 						   : NULL));
  
    delete_coalesce_list (cl);
    ssa_conflicts_delete (graph);
--- 1388,1394 ----
  
    /* Now coalesce everything in the list.  */
    coalesce_partitions (map, graph, cl,
! 		       ((dump_flags & TDF_DETAILS) ? dump_file : NULL));
  
    delete_coalesce_list (cl);
    ssa_conflicts_delete (graph);

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-03-19 10:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06 13:16 [PATCH][RFC] Fix PR63155 Richard Biener
2015-03-06 17:02 ` Jeff Law
2015-03-09  9:42   ` Richard Biener
2015-03-09 13:01     ` Richard Biener
2015-03-09 18:55       ` Jeff Law
2015-03-18 15:59       ` Alan Lawrence
2015-03-18 18:52         ` Richard Biener
2015-03-19 10:39           ` Richard Biener
2015-03-18 19:17         ` Andrew Pinski
2015-03-09 18:44     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).