@@ -8816,6 +8816,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
profitable.
+@item max-rtl-if-conversion-precitable-cost
+@item max-rtl-if-conversion-unprecitable-cost
+RTL if-conversion tries 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
The maximum number of incoming edges to consider for cross-jumping.
The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
@@ -6526,6 +6526,31 @@ should probably only be given to addresses with different numbers of
registers on machines with lots of registers.
@end deftypefn
+@deftypefn {Target Hook} {unsigned int} TARGET_MAX_NOCE_IFCVT_SEQ_COST (bool @var{speed_p}, edge @var{e})
+This hook should return 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 gives 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{speed_p} is true if we are compiling for speed.
+@code{predictable_p} is true if analysis suggests that the branch
+will be predictable. A target may decide to implement this hook to
+return a lower maximum cost for branches that the compiler believes
+will be predictable.
+
+The default implementation of this hook uses
+@code{BRANCH_COST * COSTS_N_INSNS (1)} if we are compiling for size,
+uses the @code{max-rtl-if-conversion-[un]predictable} parameters if they
+are set, and uses a multiple of @code{BRANCH_COST} if we are compiling
+for speed and the appropriate parameter is not set.
+@end deftypefn
+
@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
speculatively executed instructions being placed in delay slots. Targets
@@ -4762,6 +4762,8 @@ Define this macro if a non-short-circuit operation produced by
@hook TARGET_ADDRESS_COST
+@hook TARGET_MAX_NOCE_IFCVT_SEQ_COST
+
@hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P
@node Scheduling
@@ -1217,6 +1217,20 @@ DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_INSNS,
"if-conversion.",
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 which "
+ "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 which "
+ "is considered predictable.",
+ 40, 0, 200)
+
DEFPARAM (PARAM_HSA_GEN_DEBUG_STORES,
"hsa-gen-debug-stores",
"Level of hsa debug stores verbosity",
@@ -3572,6 +3572,35 @@ registers on machines with lots of registers.",
int, (rtx address, machine_mode mode, addr_space_t as, bool speed),
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 should return a value in the same units as\n\
+@code{TARGET_RTX_COSTS}, giving the maximum acceptable cost for\n\
+a sequence generated by the RTL if-conversion pass when conditional\n\
+execution is not available. The RTL if-conversion pass attempts\n\
+to convert conditional operations that would require a branch to a\n\
+series of unconditional operations and @code{mov@var{mode}cc} insns.\n\
+This hook gives the maximum cost of the unconditional instructions and\n\
+the @code{mov@var{mode}cc} insns. RTL if-conversion is cancelled if the\n\
+cost of the converted sequence is greater than the value returned by this\n\
+hook.\n\
+\n\
+@code{speed_p} is true if we are compiling for speed.\n\
+@code{predictable_p} is true if analysis suggests that the branch\n\
+will be predictable. A target may decide to implement this hook to\n\
+return a lower maximum cost for branches that the compiler believes\n\
+will be predictable.\n\
+\n\
+The default implementation of this hook uses\n\
+@code{BRANCH_COST * COSTS_N_INSNS (1)} if we are compiling for size,\n\
+uses the @code{max-rtl-if-conversion-[un]predictable} parameters if they\n\
+are set, and uses a multiple of @code{BRANCH_COST} if we are compiling\n\
+for speed and the appropriate parameter is not set.",
+unsigned int, (bool speed_p, edge e),
+default_max_noce_ifcvt_seq_cost)
+
/* Permit speculative instructions in delay slots during delayed-branch
scheduling. */
DEFHOOK
@@ -74,6 +74,8 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h"
#include "opts.h"
#include "gimplify.h"
+#include "predict.h"
+#include "params.h"
bool
@@ -1977,4 +1979,29 @@ default_optab_supported_p (int, machine_mode, machine_mode, optimization_type)
return true;
}
+/* Default implementation of TARGET_RTX_BRANCH_COST. */
+
+unsigned int
+default_max_noce_ifcvt_seq_cost (bool speed_p, edge e)
+{
+ bool predictable_p = predictable_edge_p (e);
+ /* For size, some targets like to set a BRANCH_COST of zero to disable
+ ifcvt, continue to allow that. Then multiply through by
+ COSTS_N_INSNS (1) so we're in a comparable base. */
+
+ if (!speed_p)
+ return BRANCH_COST (speed_p, predictable_p) * COSTS_N_INSNS (1);
+
+ 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 (speed_p, predictable_p) * COSTS_N_INSNS (3);
+}
+
#include "gt-targhooks.h"
@@ -255,4 +255,6 @@ extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE
extern bool default_optab_supported_p (int, machine_mode, machine_mode,
optimization_type);
+extern unsigned int default_max_noce_ifcvt_seq_cost (bool, edge);
+
#endif /* GCC_TARGHOOKS_H */