On 10/20/2021 6:37 AM, Aldy Hernandez wrote:
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.

OK for trunk?

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.
OK
jeff

Reply via email to