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]

[tree-ssa] Misc. var coalescing patches.


Just a few little things relating to variable coalescing. 

Bootstrapped, etc.

Andrew.

	* tree-dfa.c (add_stmt_operand): Don't treat complex types as scalars.
	* tree-ssa-live.c (var_union):  Change comment.
	(coalesce_tpa_members): Don't proceed if var_union fails.
	* tree-ssa.c (insert_copy_on_edge): Change comment.
	(coalesce_abnormal_edges): Handle var_union failing.
	(coalesce_vars): Skip constant PHI arguments.



Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.136
diff -c -p -r1.1.4.136 tree-dfa.c
*** tree-dfa.c	28 Jul 2003 17:16:19 -0000	1.1.4.136
--- tree-dfa.c	30 Jul 2003 20:09:12 -0000
*************** add_stmt_operand (tree *var_p, tree stmt
*** 565,571 ****
    /* If the original variable is not a scalar, it will be added to the list
       of virtual operands.  In that case, use its base symbol as the virtual
       variable representing it.  */
!   is_scalar = (SSA_VAR_P (var) && !AGGREGATE_TYPE_P (TREE_TYPE (var)));
    if (!is_scalar && !DECL_P (var))
      var = get_virtual_var (var);
  
--- 565,573 ----
    /* If the original variable is not a scalar, it will be added to the list
       of virtual operands.  In that case, use its base symbol as the virtual
       variable representing it.  */
!   is_scalar = (SSA_VAR_P (var)
!                && !AGGREGATE_TYPE_P (TREE_TYPE (var))
! 	       && TREE_CODE (TREE_TYPE (var)) != COMPLEX_TYPE);
    if (!is_scalar && !DECL_P (var))
      var = get_virtual_var (var);
  
Index: tree-ssa-live.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-live.c,v
retrieving revision 1.1.2.13
diff -c -p -r1.1.2.13 tree-ssa-live.c
*** tree-ssa-live.c	29 Jul 2003 04:45:58 -0000	1.1.2.13
--- tree-ssa-live.c	30 Jul 2003 20:09:17 -0000
*************** register_ssa_partition (var_map map, tre
*** 128,134 ****
      }
  }
  
! /* This function will combine 2 partitions.  */
  
  int
  var_union (var_map map, tree var1, tree var2)
--- 128,136 ----
      }
  }
  
! /* This function will combine 2 partitions.  Returns the partition which 
!    represents the new partition. If the two partitions cannot be combined, 
!    NO_PARTITION is returned. */
  
  int
  var_union (var_map map, tree var1, tree var2)
*************** coalesce_tpa_members (tpa_p tpa, conflic
*** 1300,1309 ****
  	      if (tpa_find_tree (tpa, x) == TPA_NONE 
  		  || tpa_find_tree (tpa, y) == TPA_NONE)
  		continue;
- 	      conflict_graph_merge_regs (graph, x, y);
  	      var = partition_to_var (map, x);
  	      tmp = partition_to_var (map, y);
  	      z = var_union (map, var, tmp);
  	      /* z is the new combined partition. We need to remove the other
  	         partition from the list. Set x to be that other partition.  */
  	      if (z == x)
--- 1302,1314 ----
  	      if (tpa_find_tree (tpa, x) == TPA_NONE 
  		  || tpa_find_tree (tpa, y) == TPA_NONE)
  		continue;
  	      var = partition_to_var (map, x);
  	      tmp = partition_to_var (map, y);
  	      z = var_union (map, var, tmp);
+ 	      if (z == NO_PARTITION)
+ 	        continue;
+ 	      conflict_graph_merge_regs (graph, x, y);
+ 
  	      /* z is the new combined partition. We need to remove the other
  	         partition from the list. Set x to be that other partition.  */
  	      if (z == x)
*************** coalesce_tpa_members (tpa_p tpa, conflic
*** 1344,1351 ****
  		  if (tpa_find_tree (tpa, y) == TPA_NONE 
  		      || tpa_find_tree (tpa, z) == TPA_NONE)
  		    continue;
! 		  /* Var might change as a result of the var_union.  */
! 		  var_union (map, var, tmp);
  		  tpa_remove_partition (tpa, x, z);
  		  conflict_graph_merge_regs (graph, y, z);
  		  if (debug)
--- 1349,1357 ----
  		  if (tpa_find_tree (tpa, y) == TPA_NONE 
  		      || tpa_find_tree (tpa, z) == TPA_NONE)
  		    continue;
! 		  if (var_union (map, var, tmp) == NO_PARTITION)
! 		    continue;
! 
  		  tpa_remove_partition (tpa, x, z);
  		  conflict_graph_merge_regs (graph, y, z);
  		  if (debug)
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.112
diff -c -p -r1.1.4.112 tree-ssa.c
*** tree-ssa.c	29 Jul 2003 11:10:06 -0000	1.1.4.112
--- tree-ssa.c	30 Jul 2003 20:09:19 -0000
*************** create_temp (tree t)
*** 868,875 ****
  }
  
  
! /* This helper function fill insert a copy from one variable to another
!    on the specified edge.  */
  
  static void
  insert_copy_on_edge (edge e, tree dest, tree src)
--- 868,875 ----
  }
  
  
! /* This helper function fill insert a copy from a constant or a variable to 
!    a variable on the specified edge.  */
  
  static void
  insert_copy_on_edge (edge e, tree dest, tree src)
*************** coalesce_abnormal_edges (var_map map, co
*** 1254,1260 ****
  			print_exprs (dump_file, "ABNORMAL: Coalescing ", var,
  				     " and ", tmp, " over abnormal edge.\n");
  		      }
! 		    var_union (map, var, tmp);
  		    conflict_graph_merge_regs (graph, x, y);
  		  }
  		else
--- 1254,1267 ----
  			print_exprs (dump_file, "ABNORMAL: Coalescing ", var,
  				     " and ", tmp, " over abnormal edge.\n");
  		      }
! 		    if (var_union (map, var, tmp) == NO_PARTITION)
! 		      {
! 			print_exprs (stderr, "\nUnable to coalesce", 
! 				     partition_to_var (map, x), " and ", 
! 				     partition_to_var (map, y),
! 				     " across an abnormal edge\n");
! 			abort ();
! 		      }
  		    conflict_graph_merge_regs (graph, x, y);
  		  }
  		else
*************** coalesce_vars (var_map map, tree_live_in
*** 1518,1524 ****
       becomes live on entry to the block. Mark these now.  */
    FOR_EACH_BB (bb)
      {
!       tree phi;
        int p;
        for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	{
--- 1525,1531 ----
       becomes live on entry to the block. Mark these now.  */
    FOR_EACH_BB (bb)
      {
!       tree phi, arg;
        int p;
        for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	{
*************** coalesce_vars (var_map map, tree_live_in
*** 1533,1539 ****
  	     which are not coalesced to the result to the coalesce list.  */
  	  for (x = 0; x < PHI_NUM_ARGS (phi); x++)
  	    {
! 	      p2 = var_to_partition (map, PHI_ARG_DEF (phi, x));
  #ifdef ENABLE_CHECKING
  	      if (p2 == NO_PARTITION)
  	        abort();
--- 1540,1549 ----
  	     which are not coalesced to the result to the coalesce list.  */
  	  for (x = 0; x < PHI_NUM_ARGS (phi); x++)
  	    {
! 	      arg = PHI_ARG_DEF (phi, x);
! 	      if (TREE_CONSTANT (arg))
! 	        continue;
! 	      p2 = var_to_partition (map, arg);
  #ifdef ENABLE_CHECKING
  	      if (p2 == NO_PARTITION)
  	        abort();


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