tree result;
gimple *stmt_to_move = NULL;
gimple *stmt_to_move_alt = NULL;
- auto_bitmap inserted_exprs;
tree arg_true, arg_false;
/* Special case A ? B : B as this will always simplify to B. */
if (!result)
return false;
+ auto_bitmap exprs_maybe_dce;
+
+ /* Mark the cond statements' lhs/rhs as maybe dce. */
+ if (TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME
+ && !SSA_NAME_IS_DEFAULT_DEF (gimple_cond_lhs (stmt)))
+ bitmap_set_bit (exprs_maybe_dce,
+ SSA_NAME_VERSION (gimple_cond_lhs (stmt)));
+ if (TREE_CODE (gimple_cond_rhs (stmt)) == SSA_NAME
+ && !SSA_NAME_IS_DEFAULT_DEF (gimple_cond_rhs (stmt)))
+ bitmap_set_bit (exprs_maybe_dce,
+ SSA_NAME_VERSION (gimple_cond_rhs (stmt)));
+
gsi = gsi_last_bb (cond_bb);
/* Insert the sequence generated from gimple_simplify_phiopt. */
if (seq)
gimple *stmt = gsi_stmt (gsi1);
tree name = gimple_get_lhs (stmt);
if (name && TREE_CODE (name) == SSA_NAME)
- bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name));
+ bitmap_set_bit (exprs_maybe_dce, SSA_NAME_VERSION (name));
}
if (dump_file && (dump_flags & TDF_FOLDING))
{
/* If there was a statement to move, move it to right before
the original conditional. */
- move_stmt (stmt_to_move, &gsi, inserted_exprs);
- move_stmt (stmt_to_move_alt, &gsi, inserted_exprs);
+ move_stmt (stmt_to_move, &gsi, exprs_maybe_dce);
+ move_stmt (stmt_to_move_alt, &gsi, exprs_maybe_dce);
- replace_phi_edge_with_variable (cond_bb, e1, phi, result, inserted_exprs);
+ replace_phi_edge_with_variable (cond_bb, e1, phi, result, exprs_maybe_dce);
/* Add Statistic here even though replace_phi_edge_with_variable already
does it as we want to be able to count when match-simplify happens vs