2011-12-29 Dmitry Plotnikov <dplotnikov@ispras.ru>
gcc/
* ifcvt.c (cond_exec_process_if_block): Added check for frequency ratio.
@@ -445,6 +445,16 @@ cond_exec_process_if_block (ce_if_block_t * ce_info,
int then_n_insns, else_n_insns, n_insns;
enum rtx_code false_code;
+ /* If one of branches has significantly greater probability than the other,
+ then we'd better rely on CPU's branch prediction and block reordering
+ than putting rarely executed instructions into the pipeline. 10% ratio
+ seems like a reasonable cutoff. */
+ if (then_bb && then_bb->frequency < (test_bb->frequency / 10))
+ return FALSE;
+
+ if (else_bb && else_bb->frequency < (test_bb->frequency / 10))
+ return FALSE;
+
/* If test is comprised of && or || elements, and we've failed at handling
all of them together, just use the last test if it is the special case of
&& elements without an ELSE block. */