]> gcc.gnu.org Git - gcc.git/commit
PHIOPT: Fix diamond case of match_simplify_replacement
authorAndrew Pinski <apinski@marvell.com>
Thu, 4 May 2023 17:07:50 +0000 (10:07 -0700)
committerAndrew Pinski <apinski@marvell.com>
Fri, 5 May 2023 06:04:34 +0000 (23:04 -0700)
commit2e4e899641c0c558eabf0128ee72cb8d3999c990
treeaec860664e13af6e99d4f04d0d5f2bc6438d9a41
parent6fe385eac6ff8ecddb6cbdff2c706b27b5137006
PHIOPT: Fix diamond case of match_simplify_replacement

So it turns out I messed checking which edge was true/false for the diamond
form. The edges, e0 and e1 here are edges from the merge block but the
true/false edges are from the conditional block and with diamond/threeway,
there is a bb inbetween on both edges.
Most of the time, the check that was in match_simplify_replacement would
happen to be correct for diamond form as most of the time the first edge in
the conditional is the edge for the true side of the conditional.
This is why I didn't see the issue during bootstrap/testing.

I added a fragile gimple testcase which exposed the issue. Since there is
no way to specify the order of the edges in the gimple fe, we have to
have forwprop to swap the false/true edges (not order of them, just swapping
true/false flags) and hope not to do cleanupcfg inbetween forwprop and the
first phiopt pass. This is the fragile part really, it is not that we will
produce wrong code, just we won't hit what was the failing case.

OK? Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/109732

gcc/ChangeLog:

* tree-ssa-phiopt.cc (match_simplify_replacement): Fix the selection
of the argtrue/argfalse.

gcc/testsuite/ChangeLog:

* gcc.dg/pr109732.c: New test.
* gcc.dg/pr109732-1.c: New test.
gcc/testsuite/gcc.dg/pr109732-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr109732.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.cc
This page took 0.068619 seconds and 5 git commands to generate.