/* If-conversion support.
- Copyright (C) 2000-2019 Free Software Foundation, Inc.
+ Copyright (C) 2000-2020 Free Software Foundation, Inc.
This file is part of GCC.
#include "shrink-wrap.h"
#include "rtl-iter.h"
#include "ifcvt.h"
-#include "params.h"
#ifndef MAX_CONDITIONAL_EXECUTE
#define MAX_CONDITIONAL_EXECUTE \
{
rtx_insn *insn;
unsigned count = 0;
- unsigned param = PARAM_VALUE (PARAM_MAX_RTL_IF_CONVERSION_INSNS);
+ unsigned param = param_max_rtl_if_conversion_insns;
FOR_BB_INSNS (test_bb, insn)
{
return count > 1 && count <= param;
}
+/* Compute average of two given costs weighted by relative probabilities
+ of respective basic blocks in an IF-THEN-ELSE. E is the IF-THEN edge.
+ With P as the probability to take the IF-THEN branch, return
+ P * THEN_COST + (1 - P) * ELSE_COST. */
+static unsigned
+average_cost (unsigned then_cost, unsigned else_cost, edge e)
+{
+ return else_cost + e->probability.apply ((signed) (then_cost - else_cost));
+}
+
/* Given a simple IF-THEN-JOIN or IF-THEN-ELSE-JOIN block, attempt to convert
it without using conditional execution. Return TRUE if we were successful
at converting the block. */
&if_info->else_simple))
return false;
- if (else_bb == NULL)
- if_info->original_cost += then_cost;
- else if (speed_p)
- if_info->original_cost += MIN (then_cost, else_cost);
+ if (speed_p)
+ if_info->original_cost += average_cost (then_cost, else_cost,
+ find_edge (test_bb, then_bb));
else
if_info->original_cost += then_cost + else_cost;
vec<rtx> else_regs = vNULL;
unsigned int i;
int success_p = FALSE;
- int limit = PARAM_VALUE (PARAM_MAX_RTL_IF_CONVERSION_INSNS);
+ int limit = param_max_rtl_if_conversion_insns;
/* Build a mapping for each block to the value used for each
register. */