]> git.ipfire.org Git - thirdparty/gcc.git/commit
Attempt to resolve all incoming paths to a PHI.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 20 Oct 2021 05:29:59 +0000 (07:29 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Tue, 26 Oct 2021 06:20:11 +0000 (08:20 +0200)
commit8a04a5fb07f94a2154b362741104f9d48d3e612d
tree7bff38ae0b98c28d25f3d6c5093521844879e0fb
parentf6d012338bf87f427b7420f2f309963c29fe33ba
Attempt to resolve all incoming paths to a PHI.

The code that threads incoming paths to a PHI is duplicating what we
do generically in find_paths_to_names.  This shortcoming is actually
one of the reasons we aren't threading all possible paths into a PHI.
For example, we give up after finding one threadable path, but some
PHIs have multiple threadable paths:

      // x_5 = PHI <10(4), 20(5), ...>
      // if (x_5 > 5)

Addressing this not only fixes the oversight, but simplifies the
PHI handling code, since we can consider the PHI fully resolved upon
return.

Interestingly, for ssa-thread-12.c the main thread everything was
hinging on was unreachable.  With this patch, we call
maybe_register_path() earlier.  In doing so, the solver realizes
that any path starting with 4->8 is unreachable and can be avoided.
This caused the cascade of threadable paths that depended on this
to no longer happen.  Since threadable paths in thread[34] was the only
thing this test was testing, there's no longer anything to test.  Neat!

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::resolve_phi):
Attempt to resolve all incoming paths to a PHI.
(back_threader::resolve_def): Always return true for PHIs.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr21090.c: Adjust for threading.
* gcc.dg/tree-ssa/ssa-thread-12.c: Removed.
gcc/testsuite/gcc.dg/tree-ssa/pr21090.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-12.c [deleted file]
gcc/tree-ssa-threadbackward.c