[Bug tree-optimization/102736] [12 Regression] wrong code at -O1 -ftree-vrp by r12-3903

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Oct 14 12:23:09 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102736

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Aldy Hernandez <aldyh@gcc.gnu.org>:

https://gcc.gnu.org/g:a311163fd81babd6116e2856f4551c3ca13d8914

commit r12-4395-ga311163fd81babd6116e2856f4551c3ca13d8914
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu Oct 14 10:28:39 2021 +0200

    Do not call range_on_path_entry for SSAs defined within the path

    In the path solver, when requesting the range of an SSA for which we
    know nothing, we ask the ranger for the range incoming to the path.
    We do this by asking for all the incoming ranges to the path entry
    block and unioning them.

    The problem here is that we're asking for a range on path entry for an
    SSA which *is* defined in the path, but for which we know nothing
    about:

            some_global.1_2 = some_global;
            _3 = (char) some_global.1_2;

    This request is causing us to ask for range_on_edge of _3 on the
    incoming edges to the path.  This is a bit of nonsensical request
    because _3 isn't live on entry to the path, so ranger correctly
    returns UNDEFINED.  The proper thing is to avoid asking this in the
    first place.

    I have added a relevant assert, since it doesn't make sense to call
    range_on_path_entry for SSAs defined within the path.

    Tested on x86-64 Linux.

            PR tree-optimization/102736

    gcc/ChangeLog:

            PR tree-optimization/102736
            * gimple-range-path.cc (path_range_query::range_on_path_entry):
            Assert that the requested range is defined outside the path.
            (path_range_query::ssa_range_in_phi): Do not call
            range_on_path_entry for SSA names that are defined within the
            path.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr102736.c: New test.


More information about the Gcc-bugs mailing list