[PHIOPT/MATCH] Remove the statement to move if not used
authorAndrew Pinski <apinski@marvell.com>
Fri, 9 Jul 2021 02:23:35 +0000 (19:23 -0700)
committerAndrew Pinski <apinski@marvell.com>
Mon, 12 Jul 2021 16:29:23 +0000 (09:29 -0700)
commit3f2338b4706cdc53ab276b9a5fed7f6927404f07
treeb8da0a21805622c8d1557ac9b074e0bfb7fc6e3c
parent47113773456ade7324c5467511d97f36cced57b4
[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.
gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
gcc/tree-ssa-phiopt.c