You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
-#include "errors.h"
#include "ggc.h"
#include "tree.h"
#include "basic-block.h"
} sink_stats;
-/* Given a PHI, and one of it's arguments (DEF), find the edge for
+/* Given a PHI, and one of its arguments (DEF), find the edge for
that argument and return it. If the argument occurs twice in the PHI node,
we return NULL. */
bool
is_hidden_global_store (tree stmt)
{
- stmt_ann_t ann = stmt_ann (stmt);
- v_may_def_optype v_may_defs;
- v_must_def_optype v_must_defs;
-
/* Check virtual definitions. If we get here, the only virtual
definitions we should see are those generated by assignment
statements. */
- v_may_defs = V_MAY_DEF_OPS (ann);
- v_must_defs = V_MUST_DEF_OPS (ann);
- if (NUM_V_MAY_DEFS (v_may_defs) > 0 || NUM_V_MUST_DEFS (v_must_defs) > 0)
+ if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_VIRTUAL_DEFS))
{
tree lhs;
variable.
Therefore, we check the base address of the LHS. If the
- address is a pointer, we check if its name tag or type tag is
+ address is a pointer, we check if its name tag or symbol tag is
a global variable. Otherwise, we check if the base variable
is a global. */
lhs = TREE_OPERAND (stmt, 0);
tree ptr = TREE_OPERAND (lhs, 0);
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
tree nmt = (pi) ? pi->name_mem_tag : NULL_TREE;
- tree tmt = var_ann (SSA_NAME_VAR (ptr))->type_mem_tag;
+ tree smt = var_ann (SSA_NAME_VAR (ptr))->symbol_mem_tag;
- /* If either the name tag or the type tag for PTR is a
+ /* If either the name tag or the symbol tag for PTR is a
global variable, then the store is necessary. */
if ((nmt && is_global_var (nmt))
- || (tmt && is_global_var (tmt)))
+ || (smt && is_global_var (smt)))
{
return true;
}
{
tree usestmt = USE_STMT (use_p);
basic_block useblock;
+
if (TREE_CODE (usestmt) == PHI_NODE)
{
- int j;
- for (j = 0; j < PHI_NUM_ARGS (usestmt); j++)
- {
- useblock = PHI_ARG_EDGE (usestmt, j)->src;
- /* Short circuit. Nothing dominates the entry block. */
- if (useblock == ENTRY_BLOCK_PTR)
- {
- BITMAP_FREE (blocks);
- return NULL;
- }
- bitmap_set_bit (blocks, useblock->index);
- }
+ int idx = PHI_ARG_INDEX_FROM_USE (use_p);
+
+ useblock = PHI_ARG_EDGE (usestmt, idx)->src;
}
else
{
useblock = bb_for_stmt (usestmt);
+ }
- /* Short circuit. Nothing dominates the entry block. */
- if (useblock == ENTRY_BLOCK_PTR)
- {
- BITMAP_FREE (blocks);
- return NULL;
- }
- bitmap_set_bit (blocks, useblock->index);
+ /* Short circuit. Nothing dominates the entry block. */
+ if (useblock == ENTRY_BLOCK_PTR)
+ {
+ BITMAP_FREE (blocks);
+ return NULL;
}
+ bitmap_set_bit (blocks, useblock->index);
}
}
commondom = BASIC_BLOCK (bitmap_first_set_bit (blocks));
*/
ann = stmt_ann (stmt);
- if (NUM_VUSES (STMT_VUSE_OPS (stmt)) != 0
- || stmt_ends_bb_p (stmt)
+ if (stmt_ends_bb_p (stmt)
|| TREE_SIDE_EFFECTS (rhs)
|| TREE_CODE (rhs) == EXC_PTR_EXPR
|| TREE_CODE (rhs) == FILTER_EXPR
|| is_hidden_global_store (stmt)
- || ann->has_volatile_ops)
+ || ann->has_volatile_ops
+ || !ZERO_SSA_OPERANDS (stmt, SSA_OP_VUSE))
return NULL;
FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_ALL_DEFS)
}
/* Note that at this point, all uses must be in the same statement, so it
- doesn't matter which def op we choose. */
- if (STMT_DEF_OPS (stmt) == NULL)
- {
- if (STMT_V_MAY_DEF_OPS (stmt) != NULL)
- def = V_MAY_DEF_RESULT (STMT_V_MAY_DEF_OPS (stmt), 0);
- else if (STMT_V_MUST_DEF_OPS (stmt) != NULL)
- def = V_MUST_DEF_RESULT (STMT_V_MUST_DEF_OPS (stmt), 0);
- else
- gcc_unreachable ();
- }
- else
- def = DEF_OP (STMT_DEF_OPS (stmt), 0);
+ doesn't matter which def op we choose, pick the first one. */
+ FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
+ break;
+
sinkbb = find_bb_for_arg (use, def);
if (!sinkbb)
tree stmt = bsi_stmt (bsi);
block_stmt_iterator tobsi;
tree sinkstmt;
- get_stmt_operands (stmt);
sinkstmt = statement_sink_location (stmt, bb);
if (!sinkstmt)
static void
execute_sink_code (void)
{
- struct loops *loops = loop_optimizer_init (dump_file);
+ struct loops *loops = loop_optimizer_init (LOOPS_NORMAL);
+
connect_infinite_loops_to_exit ();
memset (&sink_stats, 0, sizeof (sink_stats));
calculate_dominance_info (CDI_DOMINATORS | CDI_POST_DOMINATORS);
fprintf (dump_file, "Sunk statements:%d\n", sink_stats.sunk);
free_dominance_info (CDI_POST_DOMINATORS);
remove_fake_exit_edges ();
- loop_optimizer_finalize (loops, dump_file);
+ loop_optimizer_finalize (loops);
}
/* Gate and execute functions for PRE. */
-static void
+static unsigned int
do_sink (void)
{
execute_sink_code ();
+ return 0;
}
static bool
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- TODO_rename_vars | TODO_dump_func | TODO_ggc_collect | TODO_verify_ssa, /* todo_flags_finish */
+ TODO_update_ssa
+ | TODO_dump_func
+ | TODO_ggc_collect
+ | TODO_verify_ssa, /* todo_flags_finish */
0 /* letter */
};