+2013-07-13 Bin Cheng <bin.cheng@arm.com>
+
+ * ifcvt.c (ifcvt_after_combine): New static variable.
+ (cheap_bb_rtx_cost_p): Set scale to REG_BR_PROB_BASE when optimizing
+ for size.
+ (if_convert): New parameter after_combine. Set ifcvt_after_combine.
+ (rest_of_handle_if_conversion, rest_of_handle_if_after_combine,
+ rest_of_handle_if_after_reload): Pass new argument for if_convert.
+
2013-07-12 Maciej W. Rozycki <macro@codesourcery.com>
* config/mips/mips.c (mips_expand_call): Remove empty statement.
#define NULL_BLOCK ((basic_block) NULL)
+/* True if after combine pass. */
+static bool ifcvt_after_combine;
+
/* # of IF-THEN or IF-THEN-ELSE blocks we looked at */
static int num_possible_if_blocks;
rtx insn = BB_HEAD (bb);
bool speed = optimize_bb_for_speed_p (bb);
+ /* Set scale to REG_BR_PROB_BASE to void the identical scaling
+ applied to insn_rtx_cost when optimizing for size. Only do
+ this after combine because if-conversion might interfere with
+ passes before combine.
+
+ Use optimize_function_for_speed_p instead of the pre-defined
+ variable speed to make sure it is set to same value for all
+ basic blocks in one if-conversion transformation. */
+ if (!optimize_function_for_speed_p (cfun) && ifcvt_after_combine)
+ scale = REG_BR_PROB_BASE;
/* Our branch probability/scaling factors are just estimates and don't
account for cases where we can get speculation for free and other
secondary benefits. So we fudge the scale factor to make speculating
- appear a little more profitable. */
- scale += REG_BR_PROB_BASE / 8;
+ appear a little more profitable when optimizing for performance. */
+ else
+ scale += REG_BR_PROB_BASE / 8;
+
+
max_cost *= scale;
while (1)
return FALSE;
}
\f
-/* Main entry point for all if-conversion. */
+/* Main entry point for all if-conversion. AFTER_COMBINE is true if
+ we are after combine pass. */
static void
-if_convert (void)
+if_convert (bool after_combine)
{
basic_block bb;
int pass;
df_live_set_all_dirty ();
}
+ /* Record whether we are after combine pass. */
+ ifcvt_after_combine = after_combine;
num_possible_if_blocks = 0;
num_updated_if_blocks = 0;
num_true_changes = 0;
dump_flow_info (dump_file, dump_flags);
}
cleanup_cfg (CLEANUP_EXPENSIVE);
- if_convert ();
+ if_convert (false);
}
cleanup_cfg (0);
static unsigned int
rest_of_handle_if_after_combine (void)
{
- if_convert ();
+ if_convert (true);
return 0;
}
static unsigned int
rest_of_handle_if_after_reload (void)
{
- if_convert ();
+ if_convert (true);
return 0;
}