summaryrefslogtreecommitdiff
path: root/gcc/loop-invariant.c
diff options
context:
space:
mode:
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-11 19:34:39 +0000
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-11 19:34:39 +0000
commit2c5cdc405b013bfaa69eb12f23c1d8391826dc3c (patch)
tree5100e811789504438417f4754074c36177d090f3 /gcc/loop-invariant.c
parentbf2a1b05bc8b844197b710a9182c69b4c565dd93 (diff)
downloadgcc-2c5cdc405b013bfaa69eb12f23c1d8391826dc3c.tar.gz
PR 24265
* loop-invariant.c (may_assign_reg_p): Make sure a hard register can be assigned to. (find_invariant_insn): Do the cheapest check, may_assign_reg_p, before check_maybe_invariant. (move_invariant_reg): Use gen_move_insn instead of replacing SET_DEST with the temporary for the invariant. (move_loop_invariants): If checking is enabled, do internal consistency checks after completing the pass. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106795 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop-invariant.c')
-rw-r--r--gcc/loop-invariant.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 7765a0eda35..dc35aceed3b 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -291,7 +291,10 @@ find_exits (struct loop *loop, basic_block *body,
static bool
may_assign_reg_p (rtx x)
{
- return can_copy_p (GET_MODE (x));
+ return (can_copy_p (GET_MODE (x))
+ && (!REG_P (x)
+ || !HARD_REGISTER_P (x)
+ || REGNO_REG_CLASS (REGNO (x)) != NO_REGS));
}
/* Finds definitions that may correspond to invariants in LOOP with body BODY.
@@ -436,8 +439,8 @@ find_invariant_insn (rtx insn, bool always_reached, bool always_executed,
|| HARD_REGISTER_P (dest))
simple = false;
- if (!check_maybe_invariant (SET_SRC (set))
- || !may_assign_reg_p (SET_DEST (set)))
+ if (!may_assign_reg_p (SET_DEST (set))
+ || !check_maybe_invariant (SET_SRC (set)))
return;
if (may_trap_p (PATTERN (insn)))
@@ -793,9 +796,9 @@ move_invariant_reg (struct loop *loop, unsigned invno, struct df *df)
reg = gen_reg_rtx (GET_MODE (SET_DEST (set)));
df_pattern_emit_after (df, gen_move_insn (SET_DEST (set), reg),
BLOCK_FOR_INSN (inv->insn), inv->insn);
- SET_DEST (set) = reg;
- reorder_insns (inv->insn, inv->insn, BB_END (preheader));
- df_insn_modify (df, preheader, inv->insn);
+ df_pattern_emit_after (df, gen_move_insn (reg, SET_SRC (set)),
+ preheader, BB_END (preheader));
+ df_insn_delete (df, BLOCK_FOR_INSN (inv->insn), inv->insn);
/* Replace the uses we know to be dominated. It saves work for copy
propagation, and also it is necessary so that dependent invariants
@@ -926,4 +929,8 @@ move_loop_invariants (struct loops *loops)
free_loop_data (loops->parray[i]);
df_finish (df);
+
+#ifdef ENABLE_CHECKING
+ verify_flow_info ();
+#endif
}