/* Store motion via Lazy Code Motion on the reverse CFG.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-2013 Free Software Foundation, Inc.
This file is part of GCC.
#include "system.h"
#include "coretypes.h"
#include "tm.h"
+#include "diagnostic-core.h"
#include "toplev.h"
#include "rtl.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "flags.h"
-#include "real.h"
#include "insn-config.h"
#include "recog.h"
#include "basic-block.h"
-#include "output.h"
#include "function.h"
#include "expr.h"
#include "except.h"
#include "ggc.h"
#include "intl.h"
-#include "timevar.h"
#include "tree-pass.h"
#include "hashtab.h"
#include "df.h"
invalidate REG_EQUAL/REG_EQUIV notes for?).
- pattern_regs in st_expr should be a regset (on its own obstack).
- antic_stores and avail_stores should be VECs instead of lists.
- - store_motion_mems should be a VEC instead of a list.
+ - store_motion_mems should be a vec instead of a list.
- there should be an alloc pool for struct st_expr objects.
- investigate whether it is helpful to make the address of an st_expr
a cselib VALUE.
if (after)
return anti_dependence (x, store_pattern);
else
- return true_dependence (store_pattern, GET_MODE (store_pattern), x,
- rtx_addr_varies_p);
+ return true_dependence (store_pattern, GET_MODE (store_pattern), x);
}
/* Go through the entire rtx X, looking for any loads which might alias
static bool
store_killed_in_insn (const_rtx x, const_rtx x_regs, const_rtx insn, int after)
{
- const_rtx reg, base, note, pat;
+ const_rtx reg, note, pat;
- if (!INSN_P (insn))
+ if (! NONDEBUG_INSN_P (insn))
return false;
if (CALL_P (insn))
/* But even a const call reads its parameters. Check whether the
base of some of registers used in mem is stack pointer. */
for (reg = x_regs; reg; reg = XEXP (reg, 1))
- {
- base = find_base_term (XEXP (reg, 0));
- if (!base
- || (GET_CODE (base) == ADDRESS
- && GET_MODE (base) == Pmode
- && XEXP (base, 0) == stack_pointer_rtx))
- return true;
- }
+ if (may_be_sp_based_p (XEXP (reg, 0)))
+ return true;
return false;
}
return;
/* If we are handling exceptions, we must be careful with memory references
- that may trap. If we are not, the behavior is undefined, so we may just
+ that may trap. If we are not, the behavior is undefined, so we may just
continue. */
- if (flag_non_call_exceptions && may_trap_p (dest))
+ if (cfun->can_throw_non_call_exceptions && may_trap_p (dest))
return;
/* Even if the destination cannot trap, the source may. In this case we'd
FOR_BB_INSNS (bb, insn)
{
- if (! INSN_P (insn))
+ if (! NONDEBUG_INSN_P (insn))
continue;
for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
memset (already_set, 0, sizeof (int) * max_gcse_regno);
FOR_BB_INSNS (bb, insn)
{
- if (! INSN_P (insn))
+ if (! NONDEBUG_INSN_P (insn))
continue;
for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
int index = EDGE_INDEX (edge_list, tmp->src, tmp->dest);
gcc_assert (index != EDGE_INDEX_NO_EDGE);
- if (! TEST_BIT (st_insert_map[index], expr->index))
+ if (! bitmap_bit_p (st_insert_map[index], expr->index))
break;
}
FOR_EACH_EDGE (tmp, ei, e->dest->preds)
{
int index = EDGE_INDEX (edge_list, tmp->src, tmp->dest);
- RESET_BIT (st_insert_map[index], expr->index);
+ bitmap_clear_bit (st_insert_map[index], expr->index);
}
insert_insn_start_basic_block (insn, bb);
return 0;
sp = 0;
ei = ei_start (bb->succs);
- sbitmap_zero (visited);
+ bitmap_clear (visited);
act = (EDGE_COUNT (ei_container (ei)) > 0 ? EDGE_I (ei_container (ei), 0) : NULL);
while (1)
bb = act->dest;
if (bb == EXIT_BLOCK_PTR
- || TEST_BIT (visited, bb->index))
+ || bitmap_bit_p (visited, bb->index))
{
if (!ei_end_p (ei))
ei_next (&ei);
act = (! ei_end_p (ei)) ? ei_edge (ei) : NULL;
continue;
}
- SET_BIT (visited, bb->index);
+ bitmap_set_bit (visited, bb->index);
- if (TEST_BIT (st_antloc[bb->index], smexpr->index))
+ if (bitmap_bit_p (st_antloc[bb->index], smexpr->index))
{
for (last = smexpr->antic_stores;
BLOCK_FOR_INSN (XEXP (last, 0)) != bb;
last = NEXT_INSN (BB_END (bb));
for (insn = BB_HEAD (bb); insn != last; insn = NEXT_INSN (insn))
- if (INSN_P (insn))
+ if (NONDEBUG_INSN_P (insn))
{
note = find_reg_equal_equiv_note (insn);
if (!note || !exp_equiv_p (XEXP (note, 0), mem, 0, true))
they are no longer accurate provided that they are reached by this
definition, so drop them. */
for (; insn != NEXT_INSN (BB_END (bb)); insn = NEXT_INSN (insn))
- if (INSN_P (insn))
+ if (NONDEBUG_INSN_P (insn))
{
set = single_set (insn);
if (!set)
/* Build the gen_vector. This is any store in the table which is not killed
by aliasing later in its block. */
st_avloc = sbitmap_vector_alloc (last_basic_block, num_stores);
- sbitmap_vector_zero (st_avloc, last_basic_block);
+ bitmap_vector_clear (st_avloc, last_basic_block);
st_antloc = sbitmap_vector_alloc (last_basic_block, num_stores);
- sbitmap_vector_zero (st_antloc, last_basic_block);
+ bitmap_vector_clear (st_antloc, last_basic_block);
for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
{
we can delete this one (It occurs earlier in the block). We'll
copy the SRC expression to an unused register in case there
are any side effects. */
- if (TEST_BIT (st_avloc[bb->index], ptr->index))
+ if (bitmap_bit_p (st_avloc[bb->index], ptr->index))
{
rtx r = gen_reg_rtx_and_attrs (ptr->pattern);
if (dump_file)
replace_store_insn (r, XEXP (st, 0), bb, ptr);
continue;
}
- SET_BIT (st_avloc[bb->index], ptr->index);
+ bitmap_set_bit (st_avloc[bb->index], ptr->index);
}
for (st = ptr->antic_stores; st != NULL; st = XEXP (st, 1))
{
insn = XEXP (st, 0);
bb = BLOCK_FOR_INSN (insn);
- SET_BIT (st_antloc[bb->index], ptr->index);
+ bitmap_set_bit (st_antloc[bb->index], ptr->index);
}
}
st_kill = sbitmap_vector_alloc (last_basic_block, num_stores);
- sbitmap_vector_zero (st_kill, last_basic_block);
+ bitmap_vector_clear (st_kill, last_basic_block);
st_transp = sbitmap_vector_alloc (last_basic_block, num_stores);
- sbitmap_vector_zero (st_transp, last_basic_block);
+ bitmap_vector_clear (st_transp, last_basic_block);
regs_set_in_block = XNEWVEC (int, max_gcse_regno);
FOR_EACH_BB (bb)
memset (regs_set_in_block, 0, sizeof (int) * max_gcse_regno);
FOR_BB_INSNS (bb, insn)
- if (INSN_P (insn))
+ if (NONDEBUG_INSN_P (insn))
{
df_ref *def_rec;
for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
{
/* It should not be necessary to consider the expression
killed if it is both anticipatable and available. */
- if (!TEST_BIT (st_antloc[bb->index], ptr->index)
- || !TEST_BIT (st_avloc[bb->index], ptr->index))
- SET_BIT (st_kill[bb->index], ptr->index);
+ if (!bitmap_bit_p (st_antloc[bb->index], ptr->index)
+ || !bitmap_bit_p (st_avloc[bb->index], ptr->index))
+ bitmap_set_bit (st_kill[bb->index], ptr->index);
}
else
- SET_BIT (st_transp[bb->index], ptr->index);
+ bitmap_set_bit (st_transp[bb->index], ptr->index);
}
}
if (dump_file)
{
- dump_sbitmap_vector (dump_file, "st_antloc", "", st_antloc, last_basic_block);
- dump_sbitmap_vector (dump_file, "st_kill", "", st_kill, last_basic_block);
- dump_sbitmap_vector (dump_file, "st_transp", "", st_transp, last_basic_block);
- dump_sbitmap_vector (dump_file, "st_avloc", "", st_avloc, last_basic_block);
+ dump_bitmap_vector (dump_file, "st_antloc", "", st_antloc, last_basic_block);
+ dump_bitmap_vector (dump_file, "st_kill", "", st_kill, last_basic_block);
+ dump_bitmap_vector (dump_file, "st_transp", "", st_transp, last_basic_block);
+ dump_bitmap_vector (dump_file, "st_avloc", "", st_avloc, last_basic_block);
}
}
/* If any of the edges we have above are abnormal, we can't move this
store. */
for (x = NUM_EDGES (edge_list) - 1; x >= 0; x--)
- if (TEST_BIT (st_insert_map[x], ptr->index)
+ if (bitmap_bit_p (st_insert_map[x], ptr->index)
&& (INDEX_EDGE (edge_list, x)->flags & EDGE_ABNORMAL))
break;
/* Now we want to insert the new stores which are going to be needed. */
FOR_EACH_BB (bb)
- if (TEST_BIT (st_delete_map[bb->index], ptr->index))
+ if (bitmap_bit_p (st_delete_map[bb->index], ptr->index))
{
delete_store (ptr, bb);
n_stores_deleted++;
}
for (x = 0; x < NUM_EDGES (edge_list); x++)
- if (TEST_BIT (st_insert_map[x], ptr->index))
+ if (bitmap_bit_p (st_insert_map[x], ptr->index))
{
did_edge_inserts |= insert_store (ptr, INDEX_EDGE (edge_list, x));
n_stores_created++;
execute_rtl_store_motion (void)
{
delete_unreachable_blocks ();
- df_note_add_problem ();
df_analyze ();
flag_rerun_cse_after_global_opts |= one_store_motion_pass ();
return 0;
{
RTL_PASS,
"store_motion", /* name */
+ OPTGROUP_NONE, /* optinfo_flags */
gate_rtl_store_motion, /* gate */
execute_rtl_store_motion, /* execute */
NULL, /* sub */
0, /* properties_destroyed */
0, /* todo_flags_start */
TODO_df_finish | TODO_verify_rtl_sharing |
- TODO_dump_func |
- TODO_verify_flow | TODO_ggc_collect /* todo_flags_finish */
+ TODO_verify_flow /* todo_flags_finish */
}
};
-