@@ -6190,6 +6190,12 @@ true for well-predicted branches. On many architectures the
@code{BRANCH_COST} can be reduced then.
@end defmac
+@deftypefn {Target Hook} bool TARGET_COSTS_IFCVT_NOCE_PROFITABLE_P (rtx_insn *@var{seq}, struct noce_if_info *@var{info})
+This hook should return TRUE if converting the IF-THEN-ELSE blocks
+ described in INFO with the if-converted sequence SEQ is expected to
+ be profitable.
+@end deftypefn
+
Here are additional macros which do not specify precise relative costs,
but only that certain actions are more expensive than GCC would
ordinarily expect.
@@ -4575,6 +4575,8 @@ true for well-predicted branches. On many architectures the
@code{BRANCH_COST} can be reduced then.
@end defmac
+@hook TARGET_COSTS_IFCVT_NOCE_PROFITABLE_P
+
Here are additional macros which do not specify precise relative costs,
but only that certain actions are more expensive than GCC would
ordinarily expect.
@@ -794,7 +794,7 @@ static bool
noce_is_profitable_p (rtx_insn *seq ATTRIBUTE_UNUSED,
struct noce_if_info *if_info)
{
- return (if_info->branch_cost >= if_info->magic_number);
+ return targetm.costs.ifcvt_noce_profitable_p (seq, if_info);
}
/* Helper function for noce_try_store_flag*. */
@@ -5876,6 +5876,21 @@ DEFHOOK
HOOK_VECTOR_END (mode_switching)
+/* Cost functions. */
+#undef HOOK_PREFIX
+#define HOOK_PREFIX "TARGET_COSTS_"
+HOOK_VECTOR (TARGET_COSTS_, costs)
+
+DEFHOOK
+(ifcvt_noce_profitable_p,
+ "This hook should return TRUE if converting the IF-THEN-ELSE blocks\n\
+ described in INFO with the if-converted sequence SEQ is expected to\n\
+ be profitable.",
+ bool, (rtx_insn *seq, struct noce_if_info *info),
+ default_ifcvt_noce_profitable_p)
+
+HOOK_VECTOR_END (costs)
+
#undef HOOK_PREFIX
#define HOOK_PREFIX "TARGET_"
@@ -82,6 +82,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimplify.h"
#include "stringpool.h"
#include "tree-ssanames.h"
+#include "ifcvt.h"
bool
@@ -1922,4 +1923,14 @@ can_use_doloop_if_innermost (const widest_int &, const widest_int &,
return loop_depth == 1;
}
+/* For the default implementation, match the legacy logic by simply
+ comparing the estimated branch cost against a magic number. */
+
+bool
+default_ifcvt_noce_profitable_p (rtx_insn *seq ATTRIBUTE_UNUSED,
+ struct noce_if_info *if_info)
+{
+ return (if_info->branch_cost >= if_info->magic_number);
+}
+
#include "gt-targhooks.h"
@@ -240,4 +240,7 @@ extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE
tree type ATTRIBUTE_UNUSED,
int *pretend_arg_size ATTRIBUTE_UNUSED,
int second_time ATTRIBUTE_UNUSED);
+
+extern bool default_ifcvt_noce_profitable_p (rtx_insn *,
+ struct noce_if_info *);
#endif /* GCC_TARGHOOKS_H */