- dataflow_t df = get_immediate_uses (stmt);
- unsigned int num_uses = num_immediate_uses (df);
- tree use;
- tree skipped_phi;
-
-
- /* If there are no uses then there is nothing left to do. */
- if (num_uses == 0)
- {
- record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
- return;
- }
-
- use = immediate_use (df, 0);
- skipped_phi = NULL;
-
- /* Skip through any PHI nodes we have already seen if the PHI
- represents the only use of this store.
-
- Note this does not handle the case where the store has
- multiple V_MAY_DEFs which all reach a set of PHI nodes in the
- same block. */
- while (num_uses == 1
- && TREE_CODE (use) == PHI_NODE
- && bitmap_bit_p (dse_gd->stores, get_stmt_uid (use)))
- {
- /* Record the first PHI we skip so that we can fix its
- uses if we find that STMT is a dead store. */
- if (!skipped_phi)
- skipped_phi = use;
-
- /* Skip past this PHI and loop again in case we had a PHI
- chain. */
- df = get_immediate_uses (use);
- num_uses = num_immediate_uses (df);
- use = immediate_use (df, 0);
- }
-
- /* If we have precisely one immediate use at this point, then we may
- have found redundant store. */
- if (num_uses == 1
- && bitmap_bit_p (dse_gd->stores, get_stmt_uid (use))
- && operand_equal_p (TREE_OPERAND (stmt, 0),
- TREE_OPERAND (use, 0), 0))
+ gimple use_stmt;
+
+ if (!dse_possible_dead_store_p (stmt, &use_stmt))
+ return;
+
+ /* If we have precisely one immediate use at this point and the
+ stores are to the same memory location or there is a chain of
+ virtual uses from stmt and the stmt which stores to that same
+ memory location, then we may have found redundant store. */
+ if ((gimple_has_lhs (use_stmt)
+ && (operand_equal_p (gimple_assign_lhs (stmt),
+ gimple_get_lhs (use_stmt), 0)))
+ || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))