PHIOPT: Add diamond bb form to factor_out_conditional_conversion
commit69f1a8af45d8a42003c21489019ddfb01d88d30d
authorAndrew Pinski <apinski@marvell.com>
Wed, 26 Apr 2023 21:55:46 +0000 (26 14:55 -0700)
committerAndrew Pinski <apinski@marvell.com>
Mon, 8 May 2023 07:36:19 +0000 (8 00:36 -0700)
treeee7ec67b17772abf0bb7d42b693acb0a54f685e2
parentbf839c154d6cdee62f222277fa29c38509f25912
PHIOPT: Add diamond bb form to factor_out_conditional_conversion

So the function factor_out_conditional_conversion already supports
diamond shaped bb forms, just need to be called for such a thing.

harden-cond-comp.c needed to be changed as we would optimize out the
conversion now and that causes the compare hardening not needing to
split the block which it was testing. So change it such that there
would be no chance of optimization.

Also add two testcases that showed the improvement. PR 103771 is
solved in ifconvert also for the vectorizer but now it is solved
in a general sense.

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

PR tree-optimization/49959
PR tree-optimization/103771

gcc/ChangeLog:

* tree-ssa-phiopt.cc (pass_phiopt::execute): Support
Diamond shapped bb form for factor_out_conditional_conversion.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/harden-cond-comp.c: Change testcase
slightly to avoid the new phiopt optimization.
* gcc.dg/tree-ssa/abs-2.c: New test.
* gcc.dg/tree-ssa/pr103771.c: New test.
gcc/testsuite/c-c++-common/torture/harden-cond-comp.c
gcc/testsuite/gcc.dg/tree-ssa/abs-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr103771.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.cc