+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>
PR tree-optimization/71947
also use other heuristics to decide whether if-conversion is likely to be
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
The maximum number of incoming edges to consider for cross-jumping.
The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
registers on machines with lots of registers.
@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)
This predicate controls the use of the eager delay slot filler to disallow
speculatively executed instructions being placed in delay slots. Targets
@hook TARGET_ADDRESS_COST
+@hook TARGET_MAX_NOCE_IFCVT_SEQ_COST
+
@hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P
@node Scheduling
"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 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,
"hsa-gen-debug-stores",
"Level of hsa debug stores verbosity",
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 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
scheduling. */
DEFHOOK
#include "intl.h"
#include "opts.h"
#include "gimplify.h"
+#include "predict.h"
+#include "params.h"
bool
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"
extern bool default_optab_supported_p (int, machine_mode, machine_mode,
optimization_type);
+extern unsigned int default_max_noce_ifcvt_seq_cost (edge);
+
#endif /* GCC_TARGHOOKS_H */