/* RTL-level loop invariant motion.
- Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
- Free Software Foundation, Inc.
+ Copyright (C) 2004-2013 Free Software Foundation, Inc.
This file is part of GCC.
#include "cfgloop.h"
#include "expr.h"
#include "recog.h"
-#include "output.h"
+#include "target.h"
#include "function.h"
#include "flags.h"
#include "df.h"
#include "params.h"
#include "regs.h"
#include "ira.h"
+#include "dumpfile.h"
/* The data stored for the loop. */
typedef struct invariant *invariant_p;
-DEF_VEC_P(invariant_p);
-DEF_VEC_ALLOC_P(invariant_p, heap);
/* The invariants. */
-static VEC(invariant_p,heap) *invariants;
+static vec<invariant_p> invariants;
/* Check the size of the invariant table and realloc if necessary. */
unsigned int new_size = DF_DEFS_TABLE_SIZE () + (DF_DEFS_TABLE_SIZE () / 4);
invariant_table = XRESIZEVEC (struct invariant *, invariant_table, new_size);
memset (&invariant_table[invariant_table_size], 0,
- (new_size - invariant_table_size) * sizeof (struct rtx_iv *));
+ (new_size - invariant_table_size) * sizeof (struct invariant *));
invariant_table_size = new_size;
}
}
switch (code)
{
- case CONST_INT:
- case CONST_DOUBLE:
- case CONST_FIXED:
+ CASE_CONST_ANY:
case SYMBOL_REF:
case CONST:
case LABEL_REF:
switch (code)
{
- case CONST_INT:
- case CONST_DOUBLE:
- case CONST_FIXED:
+ CASE_CONST_ANY:
case SYMBOL_REF:
case CONST:
case LABEL_REF:
switch (code)
{
- case CONST_INT:
- case CONST_DOUBLE:
- case CONST_FIXED:
+ CASE_CONST_ANY:
case SYMBOL_REF:
case CONST:
case LABEL_REF:
EXECUTE_IF_SET_IN_BITMAP (inv->depends_on, 0, depno, bi)
{
- dep = VEC_index (invariant_p, invariants, depno);
+ dep = invariants[depno];
find_identical_invariants (eq, dep);
}
{
unsigned i;
struct invariant *inv;
- htab_t eq = htab_create (VEC_length (invariant_p, invariants),
+ htab_t eq = htab_create (invariants.length (),
hash_invariant_expr, eq_invariant_expr, free);
- FOR_EACH_VEC_ELT (invariant_p, invariants, i, inv)
+ FOR_EACH_VEC_ELT (invariants, i, inv)
find_identical_invariants (eq, inv);
htab_delete (eq);
for (i = 0; i < loop->num_nodes; i++)
bitmap_set_bit (blocks, body[i]->index);
+ if (dump_file)
+ {
+ fprintf (dump_file,
+ "*****starting processing of loop %d ******\n",
+ loop->num);
+ }
+
df_remove_problem (df_chain);
df_process_deferred_rescans ();
df_chain_add_problem (DF_UD_CHAIN);
df_set_blocks (blocks);
+ df_set_flags (DF_RD_PRUNE_DEAD_DEFS);
df_analyze ();
+ check_invariant_table_size ();
if (dump_file)
{
df_dump_region (dump_file);
- fprintf (dump_file, "*****starting processing of loop ******\n");
- print_rtl_with_bb (dump_file, get_insns ());
- fprintf (dump_file, "*****ending processing of loop ******\n");
+ fprintf (dump_file,
+ "*****ending processing of loop %d ******\n",
+ loop->num);
}
- check_invariant_table_size ();
BITMAP_FREE (blocks);
}
inv->stamp = 0;
inv->insn = insn;
- inv->invno = VEC_length (invariant_p, invariants);
+ inv->invno = invariants.length ();
inv->eqto = ~0u;
if (def)
def->invno = inv->invno;
- VEC_safe_push (invariant_p, heap, invariants, inv);
+ invariants.safe_push (inv);
if (dump_file)
{
defs = DF_REF_CHAIN (use);
if (!defs)
- return true;
+ {
+ unsigned int regno = DF_REF_REGNO (use);
+
+ /* If this is the use of an uninitialized argument register that is
+ likely to be spilled, do not move it lest this might extend its
+ lifetime and cause reload to die. This can occur for a call to
+ a function taking complex number arguments and moving the insns
+ preparing the arguments without moving the call itself wouldn't
+ gain much in practice. */
+ if ((DF_REF_FLAGS (use) & DF_HARD_REG_LIVE)
+ && FUNCTION_ARG_REGNO_P (regno)
+ && targetm.class_likely_spilled_p (REGNO_REG_CLASS (regno)))
+ return false;
+
+ return true;
+ }
if (defs->next)
return false;
bitmap_iterator bi;
/* Find the representative of the class of the equivalent invariants. */
- inv = VEC_index (invariant_p, invariants, inv->eqto);
+ inv = invariants[inv->eqto];
*comp_cost = 0;
if (! flag_ira_loop_pressure)
{
bool check_p;
- dep = VEC_index (invariant_p, invariants, depno);
+ dep = invariants[depno];
get_inv_cost (dep, &acomp_cost, aregs_needed);
+ (int) regs_needed[pressure_class]
+ LOOP_DATA (curr_loop)->max_reg_pressure[pressure_class]
+ IRA_LOOP_RESERVED_REGS
- > ira_available_class_regs[pressure_class])
+ > ira_class_hard_regs_num[pressure_class])
break;
}
if (i < ira_pressure_classes_num)
int i, gain = 0, again;
unsigned aregs_needed[N_REG_CLASSES], invno;
- FOR_EACH_VEC_ELT (invariant_p, invariants, invno, inv)
+ FOR_EACH_VEC_ELT (invariants, invno, inv)
{
if (inv->move)
continue;
static void
set_move_mark (unsigned invno, int gain)
{
- struct invariant *inv = VEC_index (invariant_p, invariants, invno);
+ struct invariant *inv = invariants[invno];
bitmap_iterator bi;
/* Find the representative of the class of the equivalent invariants. */
- inv = VEC_index (invariant_p, invariants, inv->eqto);
+ inv = invariants[inv->eqto];
if (inv->move)
return;
unsigned i, regs_used, regs_needed[N_REG_CLASSES], new_regs[N_REG_CLASSES];
struct invariant *inv = NULL;
- if (!VEC_length (invariant_p, invariants))
+ if (!invariants.length ())
return;
if (flag_ira_loop_pressure)
static bool
move_invariant_reg (struct loop *loop, unsigned invno)
{
- struct invariant *inv = VEC_index (invariant_p, invariants, invno);
- struct invariant *repr = VEC_index (invariant_p, invariants, inv->eqto);
+ struct invariant *inv = invariants[invno];
+ struct invariant *repr = invariants[inv->eqto];
unsigned i;
basic_block preheader = loop_preheader_edge (loop)->src;
rtx reg, set, dest, note;
struct invariant *inv;
unsigned i;
- FOR_EACH_VEC_ELT (invariant_p, invariants, i, inv)
+ FOR_EACH_VEC_ELT (invariants, i, inv)
move_invariant_reg (loop, i);
if (flag_ira_loop_pressure && resize_reg_info ())
{
- FOR_EACH_VEC_ELT (invariant_p, invariants, i, inv)
+ FOR_EACH_VEC_ELT (invariants, i, inv)
if (inv->reg != NULL_RTX)
{
if (inv->orig_regno >= 0)
{
actual_stamp = 1;
- invariants = VEC_alloc (invariant_p, heap, 100);
+ invariants.create (100);
}
/* Frees the data allocated by invariant motion. */
}
}
- FOR_EACH_VEC_ELT (invariant_p, invariants, i, inv)
+ FOR_EACH_VEC_ELT (invariants, i, inv)
{
BITMAP_FREE (inv->depends_on);
free (inv);
}
- VEC_free (invariant_p, heap, invariants);
+ invariants.release ();
}
/* Move the invariants out of the LOOP. */
bitmap_initialize (&LOOP_DATA (loop)->regs_ref, ®_obstack);
bitmap_initialize (&LOOP_DATA (loop)->regs_live, ®_obstack);
}
- ira_setup_eliminable_regset ();
+ ira_setup_eliminable_regset (false);
bitmap_initialize (&curr_regs_live, ®_obstack);
FOR_EACH_BB (bb)
{
{
df_analyze ();
regstat_init_n_sets_and_refs ();
- ira_set_pseudo_classes (dump_file);
+ ira_set_pseudo_classes (true, dump_file);
calculate_loop_reg_pressure ();
regstat_free_n_sets_and_refs ();
}