aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-phiopt.c
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2021-07-08 19:23:35 -0700
committerAndrew Pinski <apinski@marvell.com>2021-07-12 09:29:23 -0700
commit3f2338b4706cdc53ab276b9a5fed7f6927404f07 (patch)
treeb8da0a21805622c8d1557ac9b074e0bfb7fc6e3c /gcc/tree-ssa-phiopt.c
parent47113773456ade7324c5467511d97f36cced57b4 (diff)
downloadgcc-3f2338b4706cdc53ab276b9a5fed7f6927404f07.zip
gcc-3f2338b4706cdc53ab276b9a5fed7f6927404f07.tar.gz
gcc-3f2338b4706cdc53ab276b9a5fed7f6927404f07.tar.bz2
[PHIOPT/MATCH] Remove the statement to move if not used
Instead of waiting for DCE to remove the unused statement, and maybe optimize another conditional, it is better if we don't move the statement and have the statement removed. OK? Bootstrapped and tested on x86_64-linux-gnu. Changes from v1: * v2: Change the order of insertation and check to see if the lhs is used rather than see if the lhs was used in the sequence. gcc/ChangeLog: * tree-ssa-phiopt.c (match_simplify_replacement): Move insert of the sequence before the movement of the statement. Check if to see if the statement is used outside of the original phi to see if we should move it. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr96928-1.c: Update to similar as pr96928.c.
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r--gcc/tree-ssa-phiopt.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 7a98b7a..c6adbbd 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1020,7 +1020,16 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
return false;
gsi = gsi_last_bb (cond_bb);
- if (stmt_to_move)
+ /* Insert the sequence generated from gimple_simplify_phiopt. */
+ if (seq)
+ gsi_insert_seq_before (&gsi, seq, GSI_CONTINUE_LINKING);
+
+ /* If there was a statement to move and the result of the statement
+ is going to be used, move it to right before the original
+ conditional. */
+ if (stmt_to_move
+ && (gimple_assign_lhs (stmt_to_move) == result
+ || !has_single_use (gimple_assign_lhs (stmt_to_move))))
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@@ -1032,8 +1041,6 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
gsi_move_before (&gsi1, &gsi);
reset_flow_sensitive_info (gimple_assign_lhs (stmt_to_move));
}
- if (seq)
- gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
replace_phi_edge_with_variable (cond_bb, e1, phi, result);