-/* Returns uid of statement STMT. */
-
-static unsigned
-get_stmt_uid (tree stmt)
-{
- if (TREE_CODE (stmt) == PHI_NODE)
- return SSA_NAME_VERSION (PHI_RESULT (stmt)) + max_stmt_uid;
-
- return stmt_ann (stmt)->uid;
-}
-
-/* Set bit UID in bitmaps GLOBAL and *LOCAL, creating *LOCAL as needed. */
-
-static void
-record_voperand_set (bitmap global, bitmap *local, unsigned int uid)
-{
- /* Lazily allocate the bitmap. Note that we do not get a notification
- when the block local data structures die, so we allocate the local
- bitmap backed by the GC system. */
- if (*local == NULL)
- *local = BITMAP_GGC_ALLOC ();
-
- /* Set the bit in the local and global bitmaps. */
- bitmap_set_bit (*local, uid);
- bitmap_set_bit (global, uid);
-}
-
-/* Initialize block local data structures. */
-
-static void
-dse_initialize_block_local_data (struct dom_walk_data *walk_data,
- basic_block bb ATTRIBUTE_UNUSED,
- bool recycled)
-{
- struct dse_block_local_data *bd
- = (struct dse_block_local_data *)
- VEC_last (void_p, walk_data->block_data_stack);
-
- /* If we are given a recycled block local data structure, ensure any
- bitmap associated with the block is cleared. */
- if (recycled)
- {
- if (bd->stores)
- bitmap_clear (bd->stores);
- }
-}
-
-/* Helper function for memory_address_same via walk_tree. Returns
- non-NULL if it finds an SSA_NAME which is part of the address,
- such that the definition of the SSA_NAME post-dominates the store
- we want to delete but not the store that we believe makes it
- redundant. This indicates that the address may change between
- the two stores. */
-
-static tree
-memory_ssa_name_same (tree *expr_p, int *walk_subtrees ATTRIBUTE_UNUSED,
- void *data)
-{
- struct address_walk_data *walk_data = (struct address_walk_data *) data;
- tree expr = *expr_p;
- tree def_stmt;
- basic_block def_bb;
-
- if (TREE_CODE (expr) != SSA_NAME)
- return NULL_TREE;
-
- /* If we've found a default definition, then there's no problem. Both
- stores will post-dominate it. And def_bb will be NULL. */
- if (SSA_NAME_IS_DEFAULT_DEF (expr))
- return NULL_TREE;
-
- def_stmt = SSA_NAME_DEF_STMT (expr);
- def_bb = bb_for_stmt (def_stmt);
-
- /* DEF_STMT must dominate both stores. So if it is in the same
- basic block as one, it does not post-dominate that store. */
- if (walk_data->store1_bb != def_bb
- && dominated_by_p (CDI_POST_DOMINATORS, walk_data->store1_bb, def_bb))
- {
- if (walk_data->store2_bb == def_bb
- || !dominated_by_p (CDI_POST_DOMINATORS, walk_data->store2_bb,
- def_bb))
- /* Return non-NULL to stop the walk. */
- return def_stmt;
- }
-
- return NULL_TREE;
-}
-
-/* Return TRUE if the destination memory address in STORE1 and STORE2
- might be modified after STORE1, before control reaches STORE2. */
-
-static bool
-memory_address_same (tree store1, tree store2)
-{
- struct address_walk_data walk_data;
-
- walk_data.store1_bb = bb_for_stmt (store1);
- walk_data.store2_bb = bb_for_stmt (store2);
-
- return (walk_tree (&GIMPLE_STMT_OPERAND (store1, 0), memory_ssa_name_same,
- &walk_data, NULL)
- == NULL);
-}
-
-/* Return the use stmt for the lhs of STMT following the virtual
- def-use chains. Returns the MODIFY_EXPR stmt which lhs is equal to
- the lhs of STMT or NULL_TREE if no such stmt can be found. */
-static tree
-get_use_of_stmt_lhs (tree stmt,
- use_operand_p * first_use_p,
- use_operand_p * use_p, tree * use_stmt)
-{
- tree usevar, lhs;
- def_operand_p def_p;
-
- if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
- return NULL_TREE;
-
- lhs = GIMPLE_STMT_OPERAND (stmt, 0);
-
- /* The stmt must have a single VDEF. */
- def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_VDEF);
- if (def_p == NULL_DEF_OPERAND_P)
- return NULL_TREE;
-
- if (!has_single_use (DEF_FROM_PTR (def_p)))
- return NULL_TREE;
- /* Get the immediate use of the def. */
- single_imm_use (DEF_FROM_PTR (def_p), use_p, use_stmt);
- gcc_assert (*use_p != NULL_USE_OPERAND_P);
- first_use_p = use_p;
- if (TREE_CODE (*use_stmt) != GIMPLE_MODIFY_STMT)
- return NULL_TREE;
-
- do
- {
- /* Look at the use stmt and see if it's LHS matches
- stmt's lhs SSA_NAME. */
- def_p = SINGLE_SSA_DEF_OPERAND (*use_stmt, SSA_OP_VDEF);
- if (def_p == NULL_DEF_OPERAND_P)
- return NULL_TREE;
-
- usevar = GIMPLE_STMT_OPERAND (*use_stmt, 0);
- if (operand_equal_p (usevar, lhs, 0))
- return *use_stmt;
-
- if (!has_single_use (DEF_FROM_PTR (def_p)))
- return NULL_TREE;
- single_imm_use (DEF_FROM_PTR (def_p), use_p, use_stmt);
- gcc_assert (*use_p != NULL_USE_OPERAND_P);
- if (TREE_CODE (*use_stmt) != GIMPLE_MODIFY_STMT)
- return NULL_TREE;
- }
- while (1);
-
- return NULL_TREE;
-}