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]

[PATCH, committed] Convert sched-rgn.c to PARAM_VALUE


	A colleague observed that GCC was not performing interblock
scheduling on unrolled loops.  I traced this back to fixed parameter
definitions in sched-rgn.c.

	The original version of haifa-sched.c contributed by IBM Haifa
Research Lab defined the limits as 30 blocks and 300 insns.  The first
version checked in to GCC had the values changed to 10/100.  I do not know
who changed the original defaults or how the appropriate compilation speed
threshold was determined.

	I am not changing the default values without assessing compile
speed and performance impact, but the values are much too small.  The
values probably should be increased at -O3 implicitly.

	The following patch at least allows the values to be adjusted with
a commandline option to the compiler instead of fixed in the build.  RTH
pre-approved the patch on IRC.

David


	* params.def (PARAM_MAX_SCHED_REGION_BLOCKS): New.
	(PARAM_MAX_SCHED_REGION_INSNS): New.
	* sched-rgn.c: Include params.h
	(MAX_RGN_BLOCKS): Delete.
	(MAX_RGN_INSNS): Delete.
	(too_large): Return bool.  Convert to PARAM_VALUE.
	* Makefile.in (sched-rgn.o): Depend on $(PARAMS_H).
	* doc/invoke.texi (param): Document max-sched-region-blocks and
	max-sched-region-insns.

Index: params.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.def,v
retrieving revision 1.38
diff -c -p -r1.38 params.def
*** params.def	3 Mar 2004 16:32:38 -0000	1.38
--- params.def	22 Mar 2004 21:59:36 -0000
*************** DEFPARAM(PARAM_MAX_RELOAD_SEARCH_INSNS,
*** 293,298 ****
--- 293,308 ----
  	 "The maximum number of instructions to search backward when looking for equivalent reload",
  	 100)
  
+ DEFPARAM(PARAM_MAX_SCHED_REGION_BLOCKS,
+ 	 "max-sched-region-blocks",
+ 	 "The maximum number of blocks in a region to be considered for interblock scheduling",
+ 	 10)
+ 
+ DEFPARAM(PARAM_MAX_SCHED_REGION_INSNS,
+ 	 "max-sched-region-insns",
+ 	 "The maximum number of insns in a region to be considered for interblock scheduling",
+ 	 100)
+ 
  /*
  Local variables:
  mode:c
Index: sched-rgn.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-rgn.c,v
retrieving revision 1.72
diff -c -p -r1.72 sched-rgn.c
*** sched-rgn.c	20 Mar 2004 04:52:57 -0000	1.72
--- sched-rgn.c	22 Mar 2004 21:59:36 -0000
*************** Software Foundation, 59 Temple Place - S
*** 63,68 ****
--- 63,69 ----
  #include "toplev.h"
  #include "recog.h"
  #include "cfglayout.h"
+ #include "params.h"
  #include "sched-int.h"
  #include "target.h"
  
*************** Software Foundation, 59 Temple Place - S
*** 83,91 ****
  #define FED_BY_SPEC_LOAD(insn)	(h_i_d[INSN_UID (insn)].fed_by_spec_load)
  #define IS_LOAD_INSN(insn)	(h_i_d[INSN_UID (insn)].is_load_insn)
  
- #define MAX_RGN_BLOCKS 10
- #define MAX_RGN_INSNS 100
- 
  /* nr_inter/spec counts interblock/speculative motion for the function.  */
  static int nr_inter, nr_spec;
  
--- 84,89 ----
*************** static int *containing_rgn;
*** 156,162 ****
  void debug_regions (void);
  static void find_single_block_region (void);
  static void find_rgns (struct edge_list *);
! static int too_large (int, int *, int *);
  
  extern void debug_live (int, int);
  
--- 154,160 ----
  void debug_regions (void);
  static void find_single_block_region (void);
  static void find_rgns (struct edge_list *);
! static bool too_large (int, int *, int *);
  
  extern void debug_live (int, int);
  
*************** find_single_block_region (void)
*** 551,569 ****
  }
  
  /* Update number of blocks and the estimate for number of insns
!    in the region.  Return 1 if the region is "too large" for interblock
!    scheduling (compile time considerations), otherwise return 0.  */
  
! static int
  too_large (int block, int *num_bbs, int *num_insns)
  {
    (*num_bbs)++;
!   (*num_insns) += (INSN_LUID (BB_END (BASIC_BLOCK (block))) -
! 		   INSN_LUID (BB_HEAD (BASIC_BLOCK (block))));
!   if ((*num_bbs > MAX_RGN_BLOCKS) || (*num_insns > MAX_RGN_INSNS))
!     return 1;
!   else
!     return 0;
  }
  
  /* Update_loop_relations(blk, hdr): Check if the loop headed by max_hdr[blk]
--- 549,566 ----
  }
  
  /* Update number of blocks and the estimate for number of insns
!    in the region.  Return true if the region is "too large" for interblock
!    scheduling (compile time considerations).  */
  
! static bool
  too_large (int block, int *num_bbs, int *num_insns)
  {
    (*num_bbs)++;
!   (*num_insns) += (INSN_LUID (BB_END (BASIC_BLOCK (block)))
! 		   - INSN_LUID (BB_HEAD (BASIC_BLOCK (block))));
! 
!   return ((*num_bbs > PARAM_VALUE (PARAM_MAX_SCHED_REGION_BLOCKS))
! 	  || (*num_insns > PARAM_VALUE (PARAM_MAX_SCHED_REGION_INSNS)));
  }
  
  /* Update_loop_relations(blk, hdr): Check if the loop headed by max_hdr[blk]
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1264
diff -c -p -r1.1264 Makefile.in
*** Makefile.in	20 Mar 2004 07:13:37 -0000	1.1264
--- Makefile.in	22 Mar 2004 21:59:37 -0000
*************** sched-deps.o : sched-deps.c $(CONFIG_H) 
*** 1816,1822 ****
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h cselib.h $(PARAMS_H) $(TM_P_H)
  sched-rgn.o : sched-rgn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
     sched-int.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
!    $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H) $(TARGET_H)
  sched-ebb.o : sched-ebb.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
     sched-int.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H) $(PARAMS_H)
--- 1816,1822 ----
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h cselib.h $(PARAMS_H) $(TM_P_H)
  sched-rgn.o : sched-rgn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
     sched-int.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
!    $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(PARAMS_H) $(TM_P_H) $(TARGET_H)
  sched-ebb.o : sched-ebb.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
     sched-int.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H) $(PARAMS_H)
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.429
diff -c -p -r1.429 invoke.texi
*** doc/invoke.texi	15 Mar 2004 21:06:45 -0000	1.429
--- doc/invoke.texi	22 Mar 2004 21:59:37 -0000
*************** The @option{reorder-block-duplicate-feed
*** 4887,4892 ****
--- 4887,4900 ----
  feedback is available and may be set to higher values than
  @option{reorder-block-duplicate} since information about the hot spots is more
  accurate.
+ 
+ @item max-sched-region-blocks
+ The maximum number of blocks in a region to be considered for
+ interblock scheduling.  The default value is 10.
+ 
+ @item max-sched-region-insns",
+ The maximum number of insns in a region to be considered for
+ interblock scheduling.  The default value is 100.
  @end table
  @end table
  


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