aboutsummaryrefslogtreecommitdiff
path: root/gcc/ifcvt.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2004-07-11 14:37:57 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2004-07-11 14:37:57 +0000
commit6fd21094e5a9d8517b00bffa08f132759baefbbc (patch)
treead634004c869136a8ba76616632680e13bc31501 /gcc/ifcvt.c
parent06a67bdd66ac806bea322b14f4e94fd03ad444f2 (diff)
downloadgcc-6fd21094e5a9d8517b00bffa08f132759baefbbc.zip
gcc-6fd21094e5a9d8517b00bffa08f132759baefbbc.tar.gz
gcc-6fd21094e5a9d8517b00bffa08f132759baefbbc.tar.bz2
rtlanal.c (insn_rtx_cost): New function, moved and renamed from combine.c's combine_insn_cost.
* rtlanal.c (insn_rtx_cost): New function, moved and renamed from combine.c's combine_insn_cost. * rtl.h (insn_rtx_cost): Prototype here. * combine.c (combine_insn_cost): Delete function. (combine_validate_cost): Update callers of combine_insn_cost to call insn_rtx_cost instead. (combine_instructions): Likewise. Use NONJUMP_INSN_P to avoid requesting the rtx_cost of call and/or jump instructions. * ifcvt.c (total_bb_rtx_cost): Use insn_rtx_cost instead of calling rtx_cost directly. Don't request/use the cost of call or jump instructions. Return -1 if the cost of any instruction can't be determined (or the BB contains a function call). (find_if_case_1): Abort transformation if total_bb_rtx_cost returns -1 (i.e. can't determine the cost of any instruction or the basic block contains a subroutine call). (find_if_case_2): Likewise. From-SVN: r84513
Diffstat (limited to 'gcc/ifcvt.c')
-rw-r--r--gcc/ifcvt.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 457fb37..ac478af 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -161,7 +161,9 @@ count_bb_insns (basic_block bb)
return count;
}
-/* Count the total rtx_cost of non-jump active insns in BB. */
+/* Count the total insn_rtx_cost of non-jump active insns in BB.
+ This function returns -1, if the cost of any instruction could
+ not be estimated. */
static int
total_bb_rtx_cost (basic_block bb)
@@ -171,9 +173,16 @@ total_bb_rtx_cost (basic_block bb)
while (1)
{
- if (GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == INSN)
- count += rtx_cost (PATTERN (insn), 0);
-
+ if (NONJUMP_INSN_P (insn))
+ {
+ int cost = insn_rtx_cost (PATTERN (insn));
+ if (cost == 0)
+ return -1;
+ count += cost;
+ }
+ else if (CALL_P (insn))
+ return -1;
+
if (insn == BB_END (bb))
break;
insn = NEXT_INSN (insn);
@@ -2867,7 +2876,7 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
basic_block then_bb = then_edge->dest;
basic_block else_bb = else_edge->dest, new_bb;
edge then_succ = then_bb->succ;
- int then_bb_index;
+ int then_bb_index, bb_cost;
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
@@ -2904,7 +2913,8 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
test_bb->index, then_bb->index);
/* THEN is small. */
- if (total_bb_rtx_cost (then_bb) >= COSTS_N_INSNS (BRANCH_COST))
+ bb_cost = total_bb_rtx_cost (then_bb);
+ if (bb_cost < 0 || bb_cost >= COSTS_N_INSNS (BRANCH_COST))
return FALSE;
/* Registers set are dead, or are predicable. */
@@ -2947,6 +2957,7 @@ find_if_case_2 (basic_block test_bb, edge then_edge, edge else_edge)
basic_block then_bb = then_edge->dest;
basic_block else_bb = else_edge->dest;
edge else_succ = else_bb->succ;
+ int bb_cost;
rtx note;
/* If we are partitioning hot/cold basic blocks, we don't want to
@@ -2995,7 +3006,8 @@ find_if_case_2 (basic_block test_bb, edge then_edge, edge else_edge)
test_bb->index, else_bb->index);
/* ELSE is small. */
- if (total_bb_rtx_cost (else_bb) >= COSTS_N_INSNS (BRANCH_COST))
+ bb_cost = total_bb_rtx_cost (else_bb);
+ if (bb_cost < 0 || bb_cost >= COSTS_N_INSNS (BRANCH_COST))
return FALSE;
/* Registers set are dead, or are predicable. */