ifcvt conditional execution and rtx_cost
David Edelsohn
dje@watson.ibm.com
Wed Jul 7 20:51:00 GMT 2004
>>>>> Roger Sayle writes:
Roger> Any chance that I could ask you to draw up a patch based upon my
Roger> suggestions above?
Hows the following?
David
* 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.
Index: ifcvt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ifcvt.c,v
retrieving revision 1.154
diff -c -p -r1.154 ifcvt.c
*** ifcvt.c 6 Jul 2004 21:50:47 -0000 1.154
--- ifcvt.c 7 Jul 2004 20:09:00 -0000
*************** static bool life_data_ok;
*** 86,91 ****
--- 86,92 ----
/* 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);
*************** count_bb_insns (basic_block bb)
*** 160,165 ****
--- 161,187 ----
return count;
}
+ /* Count the total rtx_cost of non-jump active insns in BB. */
+
+ static int
+ total_bb_rtx_insns (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
*************** find_if_case_1 (basic_block test_bb, edg
*** 2883,2889 ****
test_bb->index, then_bb->index);
/* THEN is small. */
! if (count_bb_insns (then_bb) > BRANCH_COST)
return FALSE;
/* Registers set are dead, or are predicable. */
--- 2905,2911 ----
test_bb->index, then_bb->index);
/* THEN is small. */
! if (total_bb_rtx_insns (then_bb) >= COSTS_N_INSNS (BRANCH_COST))
return FALSE;
/* Registers set are dead, or are predicable. */
*************** find_if_case_2 (basic_block test_bb, edg
*** 2974,2980 ****
test_bb->index, else_bb->index);
/* ELSE is small. */
! if (count_bb_insns (else_bb) > BRANCH_COST)
return FALSE;
/* Registers set are dead, or are predicable. */
--- 2996,3002 ----
test_bb->index, else_bb->index);
/* ELSE is small. */
! if (total_bb_rtx_insns (else_bb) >= COSTS_N_INSNS (BRANCH_COST))
return FALSE;
/* Registers set are dead, or are predicable. */
More information about the Gcc-patches
mailing list