summaryrefslogtreecommitdiff
path: root/gcc/rtlanal.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/rtlanal.c
parent06a67bdd66ac806bea322b14f4e94fd03ad444f2 (diff)
downloadgcc-6fd21094e5a9d8517b00bffa08f132759baefbbc.tar.gz
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/rtlanal.c')
-rw-r--r--gcc/rtlanal.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index b802e3f55d6..81d4f4024f5 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -4785,3 +4785,39 @@ num_sign_bit_copies1 (rtx x, enum machine_mode mode, rtx known_x,
return nonzero & ((HOST_WIDE_INT) 1 << (bitwidth - 1))
? 1 : bitwidth - floor_log2 (nonzero) - 1;
}
+
+/* Calculate the rtx_cost of a single instruction. A return value of
+ zero indicates an instruction pattern without a known cost. */
+
+int
+insn_rtx_cost (rtx pat)
+{
+ int i, cost;
+ rtx set;
+
+ /* Extract the single set rtx from the instruction pattern.
+ We can't use single_set since we only have the pattern. */
+ if (GET_CODE (pat) == SET)
+ set = pat;
+ else if (GET_CODE (pat) == PARALLEL)
+ {
+ set = NULL_RTX;
+ for (i = 0; i < XVECLEN (pat, 0); i++)
+ {
+ rtx x = XVECEXP (pat, 0, i);
+ if (GET_CODE (x) == SET)
+ {
+ if (set)
+ return 0;
+ set = x;
+ }
+ }
+ if (!set)
+ return 0;
+ }
+ else
+ return 0;
+
+ cost = rtx_cost (SET_SRC (set), SET);
+ return cost > 0 ? cost : COSTS_N_INSNS (1);
+}