+ /* If we ever reach our DSE candidate stmt again fail. We
+ cannot handle dead stores in loops. */
+ if (use_stmt == stmt)
+ {
+ fail = true;
+ BREAK_FROM_IMM_USE_STMT (ui);
+ }
+ /* In simple cases we can look through PHI nodes, but we
+ have to be careful with loops and with memory references
+ containing operands that are also operands of PHI nodes.
+ See gcc.c-torture/execute/20051110-*.c. */
+ else if (gimple_code (use_stmt) == GIMPLE_PHI)
+ {
+ if (temp
+ /* Make sure we are not in a loop latch block. */
+ || gimple_bb (stmt) == gimple_bb (use_stmt)
+ || dominated_by_p (CDI_DOMINATORS,
+ gimple_bb (stmt), gimple_bb (use_stmt))
+ /* We can look through PHIs to regions post-dominating
+ the DSE candidate stmt. */
+ || !dominated_by_p (CDI_POST_DOMINATORS,
+ gimple_bb (stmt), gimple_bb (use_stmt)))
+ {
+ fail = true;
+ BREAK_FROM_IMM_USE_STMT (ui);
+ }
+ temp = use_stmt;
+ }
+ /* If the statement is a use the store is not dead. */
+ else if (ref_maybe_used_by_stmt_p (use_stmt,
+ gimple_assign_lhs (stmt)))
+ {
+ fail = true;
+ BREAK_FROM_IMM_USE_STMT (ui);
+ }
+ /* If this is a store, remember it or bail out if we have
+ multiple ones (the will be in different CFG parts then). */
+ else if (gimple_vdef (use_stmt))
+ {
+ if (temp)
+ {
+ fail = true;
+ BREAK_FROM_IMM_USE_STMT (ui);
+ }
+ temp = use_stmt;
+ }
+ }