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]

PR 10776


Hi,
the testcase in PR 10776 contains insanely large initializer that
results in insanely large basic blocks containing many memory locations
and CSElib just explodes in invalidating memory location after each
store.

Since the test is inherently quadratic it appears to make sense to
simply limit number of memory locations considered.  This patch makes
the testcase at -O1 to compile in 22 seconds.  Changing the value to 10
(instead of 500 locations) reduce it to 17 seconds.

2004-01-10  Jan Hubicka  <jh@suse.cz>
	PR opt/10776
	* cselib.c: Include params.h
	(cselib_invalidate_mem):  Limit amount of nonconflicting memory
	locations.
	* params.def (PARAM_MAX_CSELIB_MEMORY_LOCATIONS): New.
	* Makefile.in (cselib.o): Depend on params.h
Index: cselib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cselib.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 cselib.c
*** cselib.c	19 Jul 2003 14:47:02 -0000	1.30
--- cselib.c	10 Jan 2004 18:06:53 -0000
*************** Software Foundation, 59 Temple Place - S
*** 39,44 ****
--- 39,45 ----
  #include "ggc.h"
  #include "hashtab.h"
  #include "cselib.h"
+ #include "params.h"
  
  static int entry_and_rtx_equal_p (const void *, const void *);
  static hashval_t get_value_hash (const void *);
*************** static void
*** 1114,1119 ****
--- 1115,1121 ----
  cselib_invalidate_mem (rtx mem_rtx)
  {
    cselib_val **vp, *v, *next;
+   int num_mems = 0;
  
    vp = &first_containing_mem;
    for (v = *vp; v != &dummy_val; v = next)
*************** cselib_invalidate_mem (rtx mem_rtx)
*** 1135,1143 ****
  	      p = &(*p)->next;
  	      continue;
  	    }
! 	  if (! cselib_mem_conflict_p (mem_rtx, x))
  	    {
  	      has_mem = true;
  	      p = &(*p)->next;
  	      continue;
  	    }
--- 1137,1147 ----
  	      p = &(*p)->next;
  	      continue;
  	    }
! 	  if (num_mems < PARAM_VALUE (PARAM_MAX_CSELIB_MEMORY_LOCATIONS)
! 	      && ! cselib_mem_conflict_p (mem_rtx, x))
  	    {
  	      has_mem = true;
+ 	      num_mems++;
  	      p = &(*p)->next;
  	      continue;
  	    }
Index: params.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.def,v
retrieving revision 1.31
diff -c -3 -p -r1.31 params.def
*** params.def	9 Nov 2003 02:37:54 -0000	1.31
--- params.def	10 Jan 2004 18:06:53 -0000
*************** DEFPARAM(PARAM_MAX_CSE_PATH_LENGTH,
*** 238,243 ****
--- 238,248 ----
  	 "The maximum length of path considered in cse",
  	 10)
  
+ DEFPARAM(PARAM_MAX_CSELIB_MEMORY_LOCATIONS,
+ 	 "max-cselib-memory-locations",
+ 	 "The maximum memory locations recorded by cselib",
+ 	 500)
+ 
  #ifdef ENABLE_GC_ALWAYS_COLLECT
  # define GGC_MIN_EXPAND_DEFAULT 0
  # define GGC_MIN_HEAPSIZE_DEFAULT 0
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1217
diff -c -3 -p -r1.1217 Makefile.in
*** Makefile.in	9 Jan 2004 01:18:35 -0000	1.1217
--- Makefile.in	10 Jan 2004 18:08:25 -0000
*************** coverage.o : coverage.c gcov-io.c $(CONF
*** 1643,1649 ****
     gt-coverage.h $(HASHTAB_H)
  cselib.o : cselib.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
     hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
!    output.h function.h cselib.h $(GGC_H) $(TM_P_H) gt-cselib.h
  cse.o : cse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
     hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
     output.h function.h $(BASIC_BLOCK_H) $(GGC_H) $(TM_P_H) $(TIMEVAR_H) \
--- 1643,1649 ----
     gt-coverage.h $(HASHTAB_H)
  cselib.o : cselib.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
     hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
!    output.h function.h cselib.h $(GGC_H) $(TM_P_H) gt-cselib.h $(PARAMS_H)
  cse.o : cse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
     hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
     output.h function.h $(BASIC_BLOCK_H) $(GGC_H) $(TM_P_H) $(TIMEVAR_H) \


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