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] Fix various -ftree-combine-temps problems


While waiting on the immediate_uses rewrite, I decided to take a look at
the perl slowdowns compared to the mainline sources.  In the process of
that investigation, I started playing with -ftree-combine-temps and
ran into a variety of problems.

Bootstrapped and regression tested i686-pc-linux-gnu.  Also verified that
I can compile code with -ftree-combine-temps without causing aborts,
segfaults and the like.

	* tree-ssa-live.h (tpa_next_partition): Correctly handle compressed
	elements.
	* tree-ssa.c (coalesce_ssa_name): New argument, flags.  Callers
	updated.  Test SSANORM_COMBINE_TEMPS in flags rather than
	flag_tree_combine_temps.
	(coalesce_vars): Either operand of a copy might not have a
	partition when rewriting a subset of the variables out of SSA form.
	(rewrite_vars_out_of_ssa): Honor -ftree-combine-temps by passing
	in SSANORM_COMBINE_TEMPS in flags argument to remove_sas_form.
	


Index: tree-ssa-live.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-live.h,v
retrieving revision 1.1.2.14
diff -c -3 -p -r1.1.2.14 tree-ssa-live.h
*** tree-ssa-live.h	19 Jan 2004 23:13:38 -0000	1.1.2.14
--- tree-ssa-live.h	29 Jan 2004 21:05:09 -0000
*************** tpa_next_partition (tpa_p tpa, int i)
*** 355,361 ****
  static inline int 
  tpa_find_tree (tpa_p tpa, int i)
  {
!   return tpa->partition_to_tree_map[i];
  }
  
  /* Compacting removes lists with single elements. This routine puts them
--- 355,375 ----
  static inline int 
  tpa_find_tree (tpa_p tpa, int i)
  {
!   int index;
! 
!   index = tpa->partition_to_tree_map[i];
!   /* When compressed, any index higher than the number of tree elements is 
!      a compressed element, so return TPA_NONE.  */
!   if (index != TPA_NONE && index >= tpa_num_trees (tpa))
!     {
! #ifdef ENABLE_CHECKING
!       if (tpa->uncompressed_num == -1)
!         abort ();
! #endif
!       index = TPA_NONE;
!     }
! 
!   return index;
  }
  
  /* Compacting removes lists with single elements. This routine puts them
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.190
diff -c -3 -p -r1.1.4.190 tree-ssa.c
*** tree-ssa.c	20 Jan 2004 03:09:18 -0000	1.1.4.190
--- tree-ssa.c	29 Jan 2004 21:05:15 -0000
*************** static int elim_unvisited_predecessor (e
*** 205,211 ****
  static void elim_backward (elim_graph, int);
  static void elim_create (elim_graph, int);
  static void eliminate_phi (edge, int, elim_graph);
! static tree_live_info_p coalesce_ssa_name (var_map);
  static void assign_vars (var_map);
  static bool replace_variable (var_map, tree *, tree *);
  static void eliminate_virtual_phis (void);
--- 205,211 ----
  static void elim_backward (elim_graph, int);
  static void elim_create (elim_graph, int);
  static void eliminate_phi (edge, int, elim_graph);
! static tree_live_info_p coalesce_ssa_name (var_map, int flags);
  static void assign_vars (var_map);
  static bool replace_variable (var_map, tree *, tree *);
  static void eliminate_virtual_phis (void);
*************** coalesce_abnormal_edges (var_map map, co
*** 1460,1470 ****
     which are associated with actual variables at this point are those which 
     are forced to be coalesced for various reason. (live on entry, live 
     across abnormal edges, etc.). 
!    Live range information is returned if flag_tree_combine_temps
!    is set, otherwise NULL.  */
  
  static tree_live_info_p
! coalesce_ssa_name (var_map map)
  {
    int num, x;
    sbitmap live;
--- 1460,1470 ----
     which are associated with actual variables at this point are those which 
     are forced to be coalesced for various reason. (live on entry, live 
     across abnormal edges, etc.). 
!    Live range information is returned if FLAGS indicates that we are
!    combining temporaries, otherwise NULL is returned.  */
  
  static tree_live_info_p
! coalesce_ssa_name (var_map map, int flags)
  {
    int num, x;
    sbitmap live;
*************** coalesce_ssa_name (var_map map)
*** 1506,1512 ****
  	SET_BIT (live, x);
      }
  
!   if (!flag_tree_combine_temps)
      {
        delete_tree_live_info (liveinfo);
        liveinfo = NULL;
--- 1506,1512 ----
  	SET_BIT (live, x);
      }
  
!   if ((flags & SSANORM_COMBINE_TEMPS) == 0)
      {
        delete_tree_live_info (liveinfo);
        liveinfo = NULL;
*************** coalesce_vars (var_map map, tree_live_in
*** 1760,1769 ****
  	      if (!phi_ssa_name_p (arg))
  	        continue;
  	      p2 = var_to_partition (map, arg);
- #ifdef ENABLE_CHECKING
  	      if (p2 == NO_PARTITION)
! 	        abort();
! #endif
  	      if (p != p2)
  	        add_coalesce (cl, p, p2, 1);
  	    }
--- 1760,1767 ----
  	      if (!phi_ssa_name_p (arg))
  	        continue;
  	      p2 = var_to_partition (map, arg);
  	      if (p2 == NO_PARTITION)
! 		continue;
  	      if (p != p2)
  	        add_coalesce (cl, p, p2, 1);
  	    }
*************** remove_ssa_form (FILE *dump, var_map map
*** 2507,2513 ****
    if (tree_dump_file && (tree_dump_flags & TDF_DETAILS))
      dump_var_map (tree_dump_file, map);
  
!   liveinfo = coalesce_ssa_name (map);
  
    if (tree_dump_file && (tree_dump_flags & TDF_DETAILS))
      {
--- 2505,2511 ----
    if (tree_dump_file && (tree_dump_flags & TDF_DETAILS))
      dump_var_map (tree_dump_file, map);
  
!   liveinfo = coalesce_ssa_name (map, flags);
  
    if (tree_dump_file && (tree_dump_flags & TDF_DETAILS))
      {
*************** rewrite_vars_out_of_ssa (bitmap vars)
*** 2580,2585 ****
--- 2578,2584 ----
        basic_block bb;
        tree phi;
        int i;
+       int ssa_flags;
  
        /* Search for PHIs in which one of the PHI arguments is marked for
  	 translation out of SSA form, but for which the PHI result is not
*************** rewrite_vars_out_of_ssa (bitmap vars)
*** 2663,2669 ****
  
        /* Now that we have all the partitions registered, translate the
  	 appropriate variables out of SSA form.  */
!       remove_ssa_form (tree_dump_file, map, 0);
  
        /* And finally, reset the out_of_ssa flag for each of the vars
  	 we just took out of SSA form.  */
--- 2662,2672 ----
  
        /* Now that we have all the partitions registered, translate the
  	 appropriate variables out of SSA form.  */
!       if (flag_tree_combine_temps)
! 	ssa_flags = SSANORM_COMBINE_TEMPS;
!       else
! 	ssa_flags = 0;
!       remove_ssa_form (tree_dump_file, map, ssa_flags);
  
        /* And finally, reset the out_of_ssa flag for each of the vars
  	 we just took out of SSA form.  */




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