Commit e914c11a by James Greenhalgh Committed by James Greenhalgh

[Patch 1/2 ifcvt costs] New target hook: max_noce_ifcvt_seq_cost

gcc/

	* target.def (max_noce_ifcvt_seq_cost): New.
	* doc/tm.texi.in (TARGET_MAX_NOCE_IFCVT_SEQ_COST): Document it.
	* doc/tm.texi: Regenerate.
	* targhooks.h (default_max_noce_ifcvt_seq_cost): New.
	* targhooks.c (default_max_noce_ifcvt_seq_cost): New.
	* params.def (PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST): New.
	(PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST): Likewise.
	* doc/invoke.texi: Document new params.

From-SVN: r238593
parent 959cef74
2016-07-21 James Greenhalgh <james.greenhalgh@arm.com>
* target.def (max_noce_ifcvt_seq_cost): New.
* doc/tm.texi.in (TARGET_MAX_NOCE_IFCVT_SEQ_COST): Document it.
* doc/tm.texi: Regenerate.
* targhooks.h (default_max_noce_ifcvt_seq_cost): New.
* targhooks.c (default_max_noce_ifcvt_seq_cost): New.
* params.def (PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST): New.
(PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST): Likewise.
* doc/invoke.texi: Document new params.
2016-07-21 Richard Biener <rguenther@suse.de> 2016-07-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/71947 PR tree-optimization/71947
......
...@@ -8869,6 +8869,17 @@ considered for if-conversion. The default is 10, though the compiler will ...@@ -8869,6 +8869,17 @@ considered for if-conversion. The default is 10, though the compiler will
also use other heuristics to decide whether if-conversion is likely to be also use other heuristics to decide whether if-conversion is likely to be
profitable. profitable.
@item max-rtl-if-conversion-predictable-cost
@item max-rtl-if-conversion-unpredictable-cost
RTL if-conversion will try to remove conditional branches around a block
and replace them with conditionally executed instructions. These parameters
give the maximum permissible cost for the sequence that would be generated
by if-conversion depending on whether the branch is statically determined
to be predictable or not. The units for this parameter are the same as
those for the GCC internal seq_cost metric. The compiler will try to
provide a reasonable default for this parameter using the BRANCH_COST
target macro.
@item max-crossjump-edges @item max-crossjump-edges
The maximum number of incoming edges to consider for cross-jumping. The maximum number of incoming edges to consider for cross-jumping.
The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
......
...@@ -6526,6 +6526,26 @@ should probably only be given to addresses with different numbers of ...@@ -6526,6 +6526,26 @@ should probably only be given to addresses with different numbers of
registers on machines with lots of registers. registers on machines with lots of registers.
@end deftypefn @end deftypefn
@deftypefn {Target Hook} {unsigned int} TARGET_MAX_NOCE_IFCVT_SEQ_COST (edge @var{e})
This hook returns a value in the same units as @code{TARGET_RTX_COSTS},
giving the maximum acceptable cost for a sequence generated by the RTL
if-conversion pass when conditional execution is not available.
The RTL if-conversion pass attempts to convert conditional operations
that would require a branch to a series of unconditional operations and
@code{mov@var{mode}cc} insns. This hook returns the maximum cost of the
unconditional instructions and the @code{mov@var{mode}cc} insns.
RTL if-conversion is cancelled if the cost of the converted sequence
is greater than the value returned by this hook.
@code{e} is the edge between the basic block containing the conditional
branch to the basic block which would be executed if the condition
were true.
The default implementation of this hook uses the
@code{max-rtl-if-conversion-[un]predictable} parameters if they are set,
and uses a multiple of @code{BRANCH_COST} otherwise.
@end deftypefn
@deftypefn {Target Hook} bool TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P (void) @deftypefn {Target Hook} bool TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P (void)
This predicate controls the use of the eager delay slot filler to disallow This predicate controls the use of the eager delay slot filler to disallow
speculatively executed instructions being placed in delay slots. Targets speculatively executed instructions being placed in delay slots. Targets
......
...@@ -4762,6 +4762,8 @@ Define this macro if a non-short-circuit operation produced by ...@@ -4762,6 +4762,8 @@ Define this macro if a non-short-circuit operation produced by
@hook TARGET_ADDRESS_COST @hook TARGET_ADDRESS_COST
@hook TARGET_MAX_NOCE_IFCVT_SEQ_COST
@hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P @hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P
@node Scheduling @node Scheduling
......
...@@ -1222,6 +1222,20 @@ DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_INSNS, ...@@ -1222,6 +1222,20 @@ DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_INSNS,
"if-conversion.", "if-conversion.",
10, 0, 99) 10, 0, 99)
DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST,
"max-rtl-if-conversion-predictable-cost",
"Maximum permissible cost for the sequence that would be "
"generated by the RTL if-conversion pass for a branch that "
"is considered predictable.",
20, 0, 200)
DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST,
"max-rtl-if-conversion-unpredictable-cost",
"Maximum permissible cost for the sequence that would be "
"generated by the RTL if-conversion pass for a branch that "
"is considered unpredictable.",
40, 0, 200)
DEFPARAM (PARAM_HSA_GEN_DEBUG_STORES, DEFPARAM (PARAM_HSA_GEN_DEBUG_STORES,
"hsa-gen-debug-stores", "hsa-gen-debug-stores",
"Level of hsa debug stores verbosity", "Level of hsa debug stores verbosity",
......
...@@ -3586,6 +3586,30 @@ registers on machines with lots of registers.", ...@@ -3586,6 +3586,30 @@ registers on machines with lots of registers.",
int, (rtx address, machine_mode mode, addr_space_t as, bool speed), int, (rtx address, machine_mode mode, addr_space_t as, bool speed),
default_address_cost) default_address_cost)
/* Give a cost, in RTX Costs units, for an edge. Like BRANCH_COST, but with
well defined units. */
DEFHOOK
(max_noce_ifcvt_seq_cost,
"This hook returns a value in the same units as @code{TARGET_RTX_COSTS},\n\
giving the maximum acceptable cost for a sequence generated by the RTL\n\
if-conversion pass when conditional execution is not available.\n\
The RTL if-conversion pass attempts to convert conditional operations\n\
that would require a branch to a series of unconditional operations and\n\
@code{mov@var{mode}cc} insns. This hook returns the maximum cost of the\n\
unconditional instructions and the @code{mov@var{mode}cc} insns.\n\
RTL if-conversion is cancelled if the cost of the converted sequence\n\
is greater than the value returned by this hook.\n\
\n\
@code{e} is the edge between the basic block containing the conditional\n\
branch to the basic block which would be executed if the condition\n\
were true.\n\
\n\
The default implementation of this hook uses the\n\
@code{max-rtl-if-conversion-[un]predictable} parameters if they are set,\n\
and uses a multiple of @code{BRANCH_COST} otherwise.",
unsigned int, (edge e),
default_max_noce_ifcvt_seq_cost)
/* Permit speculative instructions in delay slots during delayed-branch /* Permit speculative instructions in delay slots during delayed-branch
scheduling. */ scheduling. */
DEFHOOK DEFHOOK
......
...@@ -74,6 +74,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -74,6 +74,8 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h" #include "intl.h"
#include "opts.h" #include "opts.h"
#include "gimplify.h" #include "gimplify.h"
#include "predict.h"
#include "params.h"
bool bool
...@@ -1986,4 +1988,24 @@ default_optab_supported_p (int, machine_mode, machine_mode, optimization_type) ...@@ -1986,4 +1988,24 @@ default_optab_supported_p (int, machine_mode, machine_mode, optimization_type)
return true; return true;
} }
/* Default implementation of TARGET_MAX_NOCE_IFCVT_SEQ_COST. */
unsigned int
default_max_noce_ifcvt_seq_cost (edge e)
{
bool predictable_p = predictable_edge_p (e);
enum compiler_param param
= (predictable_p
? PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST
: PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST);
/* If we have a parameter set, use that, otherwise take a guess using
BRANCH_COST. */
if (global_options_set.x_param_values[param])
return PARAM_VALUE (param);
else
return BRANCH_COST (true, predictable_p) * COSTS_N_INSNS (3);
}
#include "gt-targhooks.h" #include "gt-targhooks.h"
...@@ -256,4 +256,6 @@ extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE ...@@ -256,4 +256,6 @@ extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE
extern bool default_optab_supported_p (int, machine_mode, machine_mode, extern bool default_optab_supported_p (int, machine_mode, machine_mode,
optimization_type); optimization_type);
extern unsigned int default_max_noce_ifcvt_seq_cost (edge);
#endif /* GCC_TARGHOOKS_H */ #endif /* GCC_TARGHOOKS_H */
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