summaryrefslogtreecommitdiff
path: root/gcc/ifcvt.c
diff options
context:
space:
mode:
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-06 13:56:53 +0000
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-06 13:56:53 +0000
commit5b52bd91a85a4abc18a7e642192526f741285b95 (patch)
tree2fc0af3f16201a5d3813eb323564312466a358f8 /gcc/ifcvt.c
parent968b4f186f0f0d6d11459863d43ed5f62e49aae1 (diff)
downloadgcc-5b52bd91a85a4abc18a7e642192526f741285b95.tar.gz
* ifcvt.c (cond_move_convert_if_block): New function, code
factored out from... (cond_move_process_if_block): ...here. Call the new function on the THEN and ELSE blocks. (merge_if_block): Do not copy global_live_at_end, merge_blocks already takes care of this. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120524 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ifcvt.c')
-rw-r--r--gcc/ifcvt.c152
1 files changed, 74 insertions, 78 deletions
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index b869092ed77..553d69d26c3 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -2466,6 +2466,70 @@ check_cond_move_block (basic_block bb, rtx *vals, rtx cond)
return TRUE;
}
+/* Given a basic block BB suitable for conditional move conversion,
+ a condition COND, and arrays THEN_VALS and ELSE_VALS containing the
+ register values depending on COND, emit the insns in the block as
+ conditional moves. If ELSE_BLOCK is true, THEN_BB was already
+ processed. The caller has started a sequence for the conversion.
+ Return true if successful, false if something goes wrong. */
+
+static bool
+cond_move_convert_if_block (struct noce_if_info *if_infop,
+ basic_block bb, rtx cond,
+ rtx *then_vals, rtx *else_vals,
+ bool else_block_p)
+{
+ enum rtx_code code;
+ rtx insn, cond_arg0, cond_arg1;
+
+ code = GET_CODE (cond);
+ cond_arg0 = XEXP (cond, 0);
+ cond_arg1 = XEXP (cond, 1);
+
+ FOR_BB_INSNS (bb, insn)
+ {
+ rtx set, target, dest, t, e;
+ unsigned int regno;
+
+ if (!INSN_P (insn) || JUMP_P (insn))
+ continue;
+ set = single_set (insn);
+ gcc_assert (set && REG_P (SET_DEST (set)));
+
+ dest = SET_DEST (set);
+ regno = REGNO (dest);
+
+ t = then_vals[regno];
+ e = else_vals[regno];
+
+ if (else_block_p)
+ {
+ /* If this register was set in the then block, we already
+ handled this case there. */
+ if (t)
+ continue;
+ t = dest;
+ gcc_assert (e);
+ }
+ else
+ {
+ gcc_assert (t);
+ if (!e)
+ e = dest;
+ }
+
+ target = noce_emit_cmove (if_infop, dest, code, cond_arg0, cond_arg1,
+ t, e);
+ if (!target)
+ return false;
+
+ if (target != dest)
+ noce_emit_move_insn (dest, target);
+ }
+
+ return true;
+}
+
/* Given a simple IF-THEN or IF-THEN-ELSE block, attempt to convert it
using only conditional moves. Return TRUE if we were successful at
converting the block. */
@@ -2476,11 +2540,10 @@ cond_move_process_if_block (struct ce_if_block *ce_info)
basic_block then_bb = ce_info->then_bb;
basic_block else_bb = ce_info->else_bb;
struct noce_if_info if_info;
- rtx jump, cond, insn, seq, cond_arg0, cond_arg1, loc_insn;
+ rtx jump, cond, insn, seq, loc_insn;
int max_reg, size, c, i;
rtx *then_vals;
rtx *else_vals;
- enum rtx_code code;
if (!HAVE_conditional_move || no_new_pseudos)
return FALSE;
@@ -2537,78 +2600,18 @@ cond_move_process_if_block (struct ce_if_block *ce_info)
if (c > MAX_CONDITIONAL_EXECUTE)
return FALSE;
- /* Emit the conditional moves. First do the then block, then do
- anything left in the else blocks. */
-
- code = GET_CODE (cond);
- cond_arg0 = XEXP (cond, 0);
- cond_arg1 = XEXP (cond, 1);
-
+ /* Try to emit the conditional moves. First do the then block,
+ then do anything left in the else blocks. */
start_sequence ();
-
- FOR_BB_INSNS (then_bb, insn)
+ if (!cond_move_convert_if_block (&if_info, then_bb, cond,
+ then_vals, else_vals, false)
+ || (else_bb
+ && !cond_move_convert_if_block (&if_info, else_bb, cond,
+ then_vals, else_vals, true)))
{
- rtx set, target, dest, t, e;
- unsigned int regno;
-
- if (!INSN_P (insn) || JUMP_P (insn))
- continue;
- set = single_set (insn);
- gcc_assert (set && REG_P (SET_DEST (set)));
-
- dest = SET_DEST (set);
- regno = REGNO (dest);
- t = then_vals[regno];
- e = else_vals[regno];
- gcc_assert (t);
- if (!e)
- e = dest;
- target = noce_emit_cmove (&if_info, dest, code, cond_arg0, cond_arg1,
- t, e);
- if (!target)
- {
- end_sequence ();
- return FALSE;
- }
-
- if (target != dest)
- noce_emit_move_insn (dest, target);
- }
-
- if (else_bb)
- {
- FOR_BB_INSNS (else_bb, insn)
- {
- rtx set, target, dest;
- unsigned int regno;
-
- if (!INSN_P (insn) || JUMP_P (insn))
- continue;
- set = single_set (insn);
- gcc_assert (set && REG_P (SET_DEST (set)));
-
- dest = SET_DEST (set);
- regno = REGNO (dest);
-
- /* If this register was set in the then block, we already
- handled this case above. */
- if (then_vals[regno])
- continue;
- gcc_assert (else_vals[regno]);
-
- target = noce_emit_cmove (&if_info, dest, code, cond_arg0, cond_arg1,
- dest, else_vals[regno]);
- if (!target)
- {
- end_sequence ();
- return FALSE;
- }
-
- if (target != dest)
- noce_emit_move_insn (dest, target);
- }
+ end_sequence ();
+ return FALSE;
}
-
seq = end_ifcvt_sequence (&if_info);
if (!seq)
return FALSE;
@@ -2711,9 +2714,6 @@ merge_if_block (struct ce_if_block * ce_info)
if (then_bb)
{
- if (combo_bb->il.rtl->global_live_at_end)
- COPY_REG_SET (combo_bb->il.rtl->global_live_at_end,
- then_bb->il.rtl->global_live_at_end);
merge_blocks (combo_bb, then_bb);
num_true_changes++;
}
@@ -2764,10 +2764,6 @@ merge_if_block (struct ce_if_block * ce_info)
&& join_bb != EXIT_BLOCK_PTR)
{
/* We can merge the JOIN. */
- if (combo_bb->il.rtl->global_live_at_end)
- COPY_REG_SET (combo_bb->il.rtl->global_live_at_end,
- join_bb->il.rtl->global_live_at_end);
-
merge_blocks (combo_bb, join_bb);
num_true_changes++;
}