/* RTL-level loop invariant motion.
- Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GCC.
<http://www.gnu.org/licenses/>. */
/* This implements the loop invariant motion pass. It is very simple
- (no calls, libcalls, etc.). This should be sufficient to cleanup things
- like address arithmetics -- other more complicated invariants should be
- eliminated on tree level either in tree-ssa-loop-im.c or in tree-ssa-pre.c.
+ (no calls, no loads/stores, etc.). This should be sufficient to cleanup
+ things like address arithmetics -- other more complicated invariants should
+ be eliminated on GIMPLE either in tree-ssa-loop-im.c or in tree-ssa-pre.c.
We proceed loop by loop -- it is simpler than trying to handle things
globally and should not lose much. First we inspect all sets inside loop
/* Just handle the most trivial case where we load from an unchanging
location (most importantly, pic tables). */
- if (MEM_READONLY_P (x))
+ if (MEM_READONLY_P (x) && !MEM_VOLATILE_P (x))
break;
return false;
{
struct df_link *defs;
struct df_ref *def;
- basic_block bb = BLOCK_FOR_INSN (use->insn), def_bb;
+ basic_block bb = DF_REF_BB (use), def_bb;
if (use->flags & DF_REF_READ_WRITE)
return NULL;
FOR_BB_INSNS (body[i], insn)
{
if (CALL_P (insn)
- && !CONST_OR_PURE_CALL_P (insn))
+ && (RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)
+ || !RTL_CONST_OR_PURE_CALL_P (insn)))
{
has_call = true;
bitmap_set_bit (may_exit, i);
static bool
check_dependencies (rtx insn, bitmap depends_on)
{
+ struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
struct df_ref **use_rec;
basic_block bb = BLOCK_FOR_INSN (insn);
- for (use_rec = DF_INSN_USES (insn); *use_rec; use_rec++)
+ for (use_rec = DF_INSN_INFO_USES (insn_info); *use_rec; use_rec++)
if (!check_dependency (bb, *use_rec, depends_on))
return false;
- for (use_rec = DF_INSN_EQ_USES (insn); *use_rec; use_rec++)
+ for (use_rec = DF_INSN_INFO_EQ_USES (insn_info); *use_rec; use_rec++)
if (!check_dependency (bb, *use_rec, depends_on))
return false;
bool simple = true;
struct invariant *inv;
- /* Until we get rid of LIBCALLS. */
- if (find_reg_note (insn, REG_RETVAL, NULL_RTX)
- || find_reg_note (insn, REG_LIBCALL, NULL_RTX)
- || find_reg_note (insn, REG_NO_CONFLICT, NULL_RTX))
- return;
-
#ifdef HAVE_cc0
/* We can't move a CC0 setter without the user. */
if (sets_cc0_p (insn))
static void
record_uses (rtx insn)
{
+ struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
struct df_ref **use_rec;
struct invariant *inv;
- for (use_rec = DF_INSN_USES (insn); *use_rec; use_rec++)
+ for (use_rec = DF_INSN_INFO_USES (insn_info); *use_rec; use_rec++)
{
struct df_ref *use = *use_rec;
inv = invariant_for_use (use);
if (inv)
record_use (inv->def, DF_REF_REAL_LOC (use), DF_REF_INSN (use));
}
- for (use_rec = DF_INSN_EQ_USES (insn); *use_rec; use_rec++)
+ for (use_rec = DF_INSN_INFO_EQ_USES (insn_info); *use_rec; use_rec++)
{
struct df_ref *use = *use_rec;
inv = invariant_for_use (use);
if (always_reached
&& CALL_P (insn)
- && !CONST_OR_PURE_CALL_P (insn))
+ && (RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)
+ || ! RTL_CONST_OR_PURE_CALL_P (insn)))
always_reached = false;
}
}
need to create a temporary register. */
set = single_set (inv->insn);
dest = SET_DEST (set);
- reg = gen_reg_rtx (GET_MODE (dest));
+ reg = gen_reg_rtx_and_attrs (dest);
/* Try replacing the destination by a new pseudoregister. */
if (!validate_change (inv->insn, &SET_DEST (set), reg, false))