]> git.ipfire.org Git - thirdparty/gcc.git/commit
Port most of the A CMP 0 ? A : -A to match
authorAndrew Pinski <apinski@marvell.com>
Sun, 13 Jun 2021 02:45:20 +0000 (19:45 -0700)
committerAndrew Pinski <apinski@marvell.com>
Mon, 5 Jul 2021 19:44:14 +0000 (12:44 -0700)
commit7d6979197274a662da7bdc564314afe8415865c1
tree428f19f5ff32baafb5b7994f6ac8473a61659928
parenta50cecb20a10a729b3f5f157b154d28f9937a652
Port most of the A CMP 0 ? A : -A to match

To improve phiopt and be able to remove abs_replacement, this ports
most of "A CMP 0 ? A : -A" from fold_cond_expr_with_comparison to
match.pd.  There is a few extra changes that are needed to remove
the "A CMP 0 ? A : -A" part from fold_cond_expr_with_comparison:
   * Need to handle (A - B) case
   * Need to handle UN* comparisons.

I will handle those in a different patch.

Note phi-opt-15.c test needed to be updated as we get ABSU now
instead of not getting ABS.  When ABSU was added phiopt was not
updated even to use ABSU instead of not creating ABS.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/101039
* match.pd (A CMP 0 ? A : -A): New patterns.
* tree-ssa-phiopt.c (abs_replacement): Delete function.
(tree_ssa_phiopt_worker): Don't call abs_replacement.
Update comment about abs_replacement.

gcc/testsuite/ChangeLog:

PR tree-optimization/101039
* gcc.dg/tree-ssa/phi-opt-15.c: Update test to expect
ABSU and still not expect ABS_EXPR.
* gcc.dg/tree-ssa/phi-opt-23.c: New test.
* gcc.dg/tree-ssa/phi-opt-24.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-15.c
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c