PATCH: Corrections and improvments to register coalescing

Alex Samuel samuel@codesourcery.com
Thu Apr 6 22:49:00 GMT 2000


Corrects a couple of errors.  Also an efficiency improvement to
conflict_graph_add.

	* ssa.c (compute_conservative_reg_partition): Declare with
	void arguments.
	* toplev.c (clean_dump_file): Remove previously-deleted function
	inadvertantly merged back in.
	* conflict.c (conflict_graph_add): Use a single call to
	htab_find_slot to look up and insert.



Index: ssa.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ssa.c,v
retrieving revision 1.5
diff -c -p -r1.5 ssa.c
*** ssa.c	2000/04/06 21:22:48	1.5
--- ssa.c	2000/04/07 05:48:02
*************** static int make_regs_equivalent_over_bad
*** 139,145 ****
  static int make_equivalent_phi_alternatives_equivalent 
    PARAMS ((int bb, partition reg_partition));
  static partition compute_conservative_reg_partition 
!   PARAMS (());
  static int rename_equivalent_regs_in_insn 
    PARAMS ((rtx *ptr, void *data));
  
--- 139,145 ----
  static int make_equivalent_phi_alternatives_equivalent 
    PARAMS ((int bb, partition reg_partition));
  static partition compute_conservative_reg_partition 
!   PARAMS ((void));
  static int rename_equivalent_regs_in_insn 
    PARAMS ((rtx *ptr, void *data));


  
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.314
diff -c -p -r1.314 toplev.c
*** toplev.c	2000/04/06 21:22:48	1.314
--- toplev.c	2000/04/07 05:48:07
*************** close_dump_file (index, func, insns)
*** 1892,1917 ****
       });
  }
  
- /* Routine to empty a dump file.  */
- static void
- clean_dump_file (suffix)
-   const char *suffix;
- {
-   char * const dumpname = concat (dump_base_name, suffix, NULL);
- 
-   rtl_dump_file = fopen (dumpname, "w");
- 
-   if (rtl_dump_file == NULL)
-     pfatal_with_name (dumpname);       
- 
-   free (dumpname);
- 
-   fclose (rtl_dump_file);
-   rtl_dump_file = NULL;
-   
-   return;
- }
- 
  /* Do any final processing required for the declarations in VEC, of
     which there are LEN.  We write out inline functions and variables
     that have been deferred until this point, but which are required.
--- 1892,1897 ----



Index: conflict.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/conflict.c,v
retrieving revision 1.1
diff -c -p -r1.1 conflict.c
*** conflict.c	2000/04/06 21:22:49	1.1
--- conflict.c	2000/04/07 05:48:08
*************** conflict_graph_add (graph, reg1, reg2)
*** 201,221 ****
  {
    int smaller = MIN (reg1, reg2);
    int larger = MAX (reg1, reg2);
    conflict_graph_arc arc;
!   void **hash_table_slot;
  
    /* A reg cannot conflict with itself.  */
    if (reg1 == reg2)
      abort ();
  
!   /* If the conflict is already there, do nothing. 
! 
!      FIXME: This is a little wastful; it would be faster to look up the
!      conflict in the hash table, returning it if it exists and
!      inserting a new entry if it doesn't, all in one operation.  This
!      would save an extra hash lookup.  However, the hashtab interface
!      doesn't really allow this right now.  */
!   if (conflict_graph_conflict_p (graph, reg1, reg2))
      return 0;
  
    /* Allocate an arc.  */
--- 201,220 ----
  {
    int smaller = MIN (reg1, reg2);
    int larger = MAX (reg1, reg2);
+   struct conflict_graph_arc_def dummy;
    conflict_graph_arc arc;
!   void **slot;
  
    /* A reg cannot conflict with itself.  */
    if (reg1 == reg2)
      abort ();
  
!   dummy.smaller = smaller;
!   dummy.larger = larger;
!   slot = htab_find_slot (graph->arc_hash_table, (void *) &dummy, 1);
!   
!   /* If the conflict is already there, do nothing.  */
!   if (*slot != NULL)
      return 0;
  
    /* Allocate an arc.  */
*************** conflict_graph_add (graph, reg1, reg2)
*** 234,242 ****
    graph->neighbor_heads[larger] = arc;
  
    /* Put it in the hash table.  */
!   hash_table_slot = htab_find_slot (graph->arc_hash_table, 
! 				    (void *) arc, 1);
!   *hash_table_slot = (void *) arc;
  
    return 1;
  }
--- 233,239 ----
    graph->neighbor_heads[larger] = arc;
  
    /* Put it in the hash table.  */
!   *slot = (void *) arc;
  
    return 1;
  }
*************** conflict_graph_compute (regs, p)
*** 532,535 ****
  
    return graph;
  }
- 
--- 529,531 ----



More information about the Gcc-patches mailing list