Commit cad9aa15 by Maxim Kuvyrkov Committed by Maxim Kuvyrkov

re PR target/42495 (redundant memory load)

	PR target/42495
	PR middle-end/42574
	* basic-block.h (get_dominated_to_depth): Declare.
	* dominance.c (get_dominated_to_depth): New function, use
	get_all_dominated_blocks as a base.
	(get_all_dominated_blocks): Use get_dominated_to_depth.

	* gcse.c (occr_t, VEC (occr_t, heap)): Define.
	(hoist_exprs): Remove.
	(alloc_code_hoist_mem, free_code_hoist_mem): Update.
	(compute_code_hoist_vbeinout): Add debug print outs.
	(hoist_code): Partially rewrite, simplify.  Use get_dominated_to_depth.

	* params.def (PARAM_MAX_HOIST_DEPTH): New parameter to avoid
	quadratic behavior.
	* params.h (MAX_HOIST_DEPTH): New macro.
	* doc/invoke.texi (max-hoist-depth): Document.

From-SVN: r162597
parent 9b9ee6d3
2010-07-27 Maxim Kuvyrkov <maxim@codesourcery.com> 2010-07-27 Maxim Kuvyrkov <maxim@codesourcery.com>
PR target/42495
PR middle-end/42574
* basic-block.h (get_dominated_to_depth): Declare.
* dominance.c (get_dominated_to_depth): New function, use
get_all_dominated_blocks as a base.
(get_all_dominated_blocks): Use get_dominated_to_depth.
* gcse.c (occr_t, VEC (occr_t, heap)): Define.
(hoist_exprs): Remove.
(alloc_code_hoist_mem, free_code_hoist_mem): Update.
(compute_code_hoist_vbeinout): Add debug print outs.
(hoist_code): Partially rewrite, simplify. Use get_dominated_to_depth.
* params.def (PARAM_MAX_HOIST_DEPTH): New parameter to avoid
quadratic behavior.
* params.h (MAX_HOIST_DEPTH): New macro.
* doc/invoke.texi (max-hoist-depth): Document.
2010-07-27 Maxim Kuvyrkov <maxim@codesourcery.com>
PR rtl-optimization/40956 PR rtl-optimization/40956
* config/arm/arm.c (thumb1_size_rtx_costs): Fix cost of simple * config/arm/arm.c (thumb1_size_rtx_costs): Fix cost of simple
constants. constants.
......
...@@ -854,6 +854,8 @@ extern VEC (basic_block, heap) *get_dominated_by (enum cdi_direction, basic_bloc ...@@ -854,6 +854,8 @@ extern VEC (basic_block, heap) *get_dominated_by (enum cdi_direction, basic_bloc
extern VEC (basic_block, heap) *get_dominated_by_region (enum cdi_direction, extern VEC (basic_block, heap) *get_dominated_by_region (enum cdi_direction,
basic_block *, basic_block *,
unsigned); unsigned);
extern VEC (basic_block, heap) *get_dominated_to_depth (enum cdi_direction,
basic_block, int);
extern VEC (basic_block, heap) *get_all_dominated_blocks (enum cdi_direction, extern VEC (basic_block, heap) *get_all_dominated_blocks (enum cdi_direction,
basic_block); basic_block);
extern void add_to_dominance_info (enum cdi_direction, basic_block); extern void add_to_dominance_info (enum cdi_direction, basic_block);
......
...@@ -8260,6 +8260,12 @@ the more aggressive code hoisting will be. Specifying 0 will ...@@ -8260,6 +8260,12 @@ the more aggressive code hoisting will be. Specifying 0 will
allow all expressions to travel unrestricted distances. allow all expressions to travel unrestricted distances.
The default value is 3. The default value is 3.
@item max-hoist-depth
The depth of search in the dominator tree for expressions to hoist.
This is used to avoid quadratic behavior in hoisting algorithm.
The value of 0 will avoid limiting the search, but may slow down compilation
of huge functions. The default value is 30.
@item max-unrolled-insns @item max-unrolled-insns
The maximum number of instructions that a loop should have if that loop The maximum number of instructions that a loop should have if that loop
is unrolled, and if the loop is unrolled, it determines how many times is unrolled, and if the loop is unrolled, it determines how many times
......
...@@ -784,16 +784,20 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region, ...@@ -784,16 +784,20 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region,
} }
/* Returns the list of basic blocks including BB dominated by BB, in the /* Returns the list of basic blocks including BB dominated by BB, in the
direction DIR. The vector will be sorted in preorder. */ direction DIR up to DEPTH in the dominator tree. The DEPTH of zero will
produce a vector containing all dominated blocks. The vector will be sorted
in preorder. */
VEC (basic_block, heap) * VEC (basic_block, heap) *
get_all_dominated_blocks (enum cdi_direction dir, basic_block bb) get_dominated_to_depth (enum cdi_direction dir, basic_block bb, int depth)
{ {
VEC(basic_block, heap) *bbs = NULL; VEC(basic_block, heap) *bbs = NULL;
unsigned i; unsigned i;
unsigned next_level_start;
i = 0; i = 0;
VEC_safe_push (basic_block, heap, bbs, bb); VEC_safe_push (basic_block, heap, bbs, bb);
next_level_start = 1; /* = VEC_length (basic_block, bbs); */
do do
{ {
...@@ -804,12 +808,24 @@ get_all_dominated_blocks (enum cdi_direction dir, basic_block bb) ...@@ -804,12 +808,24 @@ get_all_dominated_blocks (enum cdi_direction dir, basic_block bb)
son; son;
son = next_dom_son (dir, son)) son = next_dom_son (dir, son))
VEC_safe_push (basic_block, heap, bbs, son); VEC_safe_push (basic_block, heap, bbs, son);
if (i == next_level_start && --depth)
next_level_start = VEC_length (basic_block, bbs);
} }
while (i < VEC_length (basic_block, bbs)); while (i < next_level_start);
return bbs; return bbs;
} }
/* Returns the list of basic blocks including BB dominated by BB, in the
direction DIR. The vector will be sorted in preorder. */
VEC (basic_block, heap) *
get_all_dominated_blocks (enum cdi_direction dir, basic_block bb)
{
return get_dominated_to_depth (dir, bb, 0);
}
/* Redirect all edges pointing to BB to TO. */ /* Redirect all edges pointing to BB to TO. */
void void
redirect_immediate_dominators (enum cdi_direction dir, basic_block bb, redirect_immediate_dominators (enum cdi_direction dir, basic_block bb,
......
...@@ -240,6 +240,14 @@ DEFPARAM(PARAM_GCSE_UNRESTRICTED_COST, ...@@ -240,6 +240,14 @@ DEFPARAM(PARAM_GCSE_UNRESTRICTED_COST,
"Cost at which GCSE optimizations will not constraint the distance an expression can travel", "Cost at which GCSE optimizations will not constraint the distance an expression can travel",
3, 0, 0) 3, 0, 0)
/* How deep from a given basic block the dominator tree should be searched
for expressions to hoist to the block. The value of 0 will avoid limiting
the search. */
DEFPARAM(PARAM_MAX_HOIST_DEPTH,
"max-hoist-depth",
"Maximum depth of search in the dominator tree for expressions to hoist",
30, 0, 0)
/* This parameter limits the number of insns in a loop that will be unrolled, /* This parameter limits the number of insns in a loop that will be unrolled,
and by how much the loop is unrolled. and by how much the loop is unrolled.
......
...@@ -129,6 +129,8 @@ typedef enum compiler_param ...@@ -129,6 +129,8 @@ typedef enum compiler_param
PARAM_VALUE (PARAM_GCSE_COST_DISTANCE_RATIO) PARAM_VALUE (PARAM_GCSE_COST_DISTANCE_RATIO)
#define GCSE_UNRESTRICTED_COST \ #define GCSE_UNRESTRICTED_COST \
PARAM_VALUE (PARAM_GCSE_UNRESTRICTED_COST) PARAM_VALUE (PARAM_GCSE_UNRESTRICTED_COST)
#define MAX_HOIST_DEPTH \
PARAM_VALUE (PARAM_MAX_HOIST_DEPTH)
#define MAX_UNROLLED_INSNS \ #define MAX_UNROLLED_INSNS \
PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS)
#define MAX_SMS_LOOP_NUMBER \ #define MAX_SMS_LOOP_NUMBER \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment