c/7344: performance regression on huge case statements
Jan Hubicka
jh@suse.cz
Fri Oct 11 08:01:00 GMT 2002
Hi,
this second patch makes CFG construction to take 0.88 second instead of
29 seconds it did originally.
Honza
Fri Oct 11 16:50:55 CEST 2002 Jan Hubicka <jh@suse.cz>
* cfgbuild.c (make_edges): Create edge cache when we do have
large jumptable.
(do_tablejump): Note size of maximal jumptable.
* function.c (prepare_function_start): Zero out size.
* function.h (function): Add max_jumptable_ents.
Index: cfgbuild.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cfgbuild.c,v
retrieving revision 1.27
diff -c -3 -p -r1.27 cfgbuild.c
*** cfgbuild.c 5 Aug 2002 18:46:32 -0000 1.27
--- cfgbuild.c 11 Oct 2002 14:49:54 -0000
*************** make_edges (label_value_list, min, max,
*** 292,298 ****
/* Heavy use of computed goto in machine-generated code can lead to
nearly fully-connected CFGs. In that case we spend a significant
amount of time searching the edge lists for duplicates. */
! if (forced_labels || label_value_list)
{
edge_cache = sbitmap_vector_alloc (last_basic_block, last_basic_block);
sbitmap_vector_zero (edge_cache, last_basic_block);
--- 292,298 ----
/* Heavy use of computed goto in machine-generated code can lead to
nearly fully-connected CFGs. In that case we spend a significant
amount of time searching the edge lists for duplicates. */
! if (forced_labels || label_value_list || cfun->max_jumptable_ents > 100)
{
edge_cache = sbitmap_vector_alloc (last_basic_block, last_basic_block);
sbitmap_vector_zero (edge_cache, last_basic_block);
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.486
diff -c -3 -p -r1.486 expr.c
*** expr.c 7 Oct 2002 07:37:09 -0000 1.486
--- expr.c 11 Oct 2002 14:49:57 -0000
*************** do_tablejump (index, mode, range, table_
*** 10941,10946 ****
--- 10930,10938 ----
enum machine_mode mode;
{
rtx temp, vector;
+
+ if (range > cfun->max_jumptable_ents)
+ cfun->max_jumptable_ents = range;
/* Do an unsigned comparison (in the proper mode) between the index
expression and the value which represents the length of the range.
Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.385
diff -c -3 -p -r1.385 function.c
*** function.c 11 Oct 2002 01:28:24 -0000 1.385
--- function.c 11 Oct 2002 14:49:59 -0000
*************** prepare_function_start ()
*** 6295,6300 ****
--- 6295,6302 ----
cfun->function_frequency = FUNCTION_FREQUENCY_NORMAL;
+ cfun->max_jumptable_ents = 0;
+
(*lang_hooks.function.init) (cfun);
if (init_machine_status)
cfun->machine = (*init_machine_status) ();
Index: function.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.h,v
retrieving revision 1.88
diff -c -3 -p -r1.88 function.h
*** function.h 22 Sep 2002 14:09:33 -0000 1.88
--- function.h 11 Oct 2002 14:49:59 -0000
*************** struct function GTY(())
*** 500,505 ****
--- 500,509 ----
(set only when profile feedback is available). */
FUNCTION_FREQUENCY_HOT
} function_frequency;
+
+ /* Maximal number of entities in the single jumptable. Used to estimate
+ final flowgraph size. */
+ int max_jumptable_ents;
};
/* The function currently being compiled. */
More information about the Gcc-patches
mailing list