+2004-07-07 David Edelsohn <edelsohn@gnu.org>
+
+ * ifcvt.c (total_bb_rtx_cost): New function.
+ (find_if_case_1): Compare rtx_cost of basic block to cost of
+ BRANCH_COST insns.
+ (find_if_case_2): Same.
+
2004-07-07 Eric Botcazou <ebotcazou@libertysurf.fr>
PR target/10567
/* Forward references. */
static int count_bb_insns (basic_block);
+static int total_bb_rtx_cost (basic_block);
static rtx first_active_insn (basic_block);
static rtx last_active_insn (basic_block, int);
static basic_block block_fallthru (basic_block);
return count;
}
+/* Count the total rtx_cost of non-jump active insns in BB. */
+
+static int
+total_bb_rtx_cost (basic_block bb)
+{
+ int count = 0;
+ rtx insn = BB_HEAD (bb);
+
+ while (1)
+ {
+ if (GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == INSN)
+ count += rtx_cost (PATTERN (insn), 0);
+
+ if (insn == BB_END (bb))
+ break;
+ insn = NEXT_INSN (insn);
+ }
+
+ return count;
+}
+
/* Return the first non-jump active insn in the basic block. */
static rtx
test_bb->index, then_bb->index);
/* THEN is small. */
- if (count_bb_insns (then_bb) > BRANCH_COST)
+ if (total_bb_rtx_cost (then_bb) >= COSTS_N_INSNS (BRANCH_COST))
return FALSE;
/* Registers set are dead, or are predicable. */
test_bb->index, else_bb->index);
/* ELSE is small. */
- if (count_bb_insns (else_bb) > BRANCH_COST)
+ if (total_bb_rtx_cost (else_bb) >= COSTS_N_INSNS (BRANCH_COST))
return FALSE;
/* Registers set are dead, or are predicable. */