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

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Richard Biener
<rgue...@gcc.gnu.org>:

https://gcc.gnu.org/g:14a16787d99831a28b0c9690e80c420d765ba26f

commit r13-8702-g14a16787d99831a28b0c9690e80c420d765ba26f
Author: Richard Biener <rguent...@suse.de>
Date:   Wed Feb 28 12:37:07 2024 +0100

    tree-optimization/114121 - wrong VN with context sensitive range info

    When VN ends up exploiting range-info specifying the ao_ref offset
    and max_size we have to make sure to reflect this in the hashtable
    entry for the recorded expression.  The PR113831 fix handled the
    case where we can encode this in the operands themselves but this
    bug shows the issue is more widespread.

    So instead of altering the operands the following instead records
    this extra info that's possibly used, only throwing it away when
    the value-numbering didn't come up with a non-VARYING value which
    is an important detail to preserve CSE as opposed to constant
    folding which is where all cases currently known popped up.

    With this the original PR113831 fix can be reverted.

            PR tree-optimization/113831
            PR tree-optimization/114121
            * tree-ssa-sccvn.h (vn_reference_s::offset,
            vn_reference_s::max_size): New fields.
            (vn_reference_insert_pieces): Adjust prototype.
            * tree-ssa-pre.cc (phi_translate_1): Preserve offset/max_size.
            * tree-ssa-sccvn.cc (vn_reference_eq): Compare offset and
            size, allow using "don't know" state.
            (vn_walk_cb_data::finish): Pass along offset/max_size.
            (vn_reference_lookup_or_insert_for_pieces): Take offset and
            max_size as argument and use it.
            (vn_reference_lookup_3): Properly adjust offset and max_size
            according to the adjusted ao_ref.
            (vn_reference_lookup_pieces): Initialize offset and max_size.
            (vn_reference_lookup): Likewise.
            (vn_reference_lookup_call): Likewise.
            (vn_reference_insert): Likewise.
            (visit_reference_op_call): Likewise.
            (vn_reference_insert_pieces): Take offset and max_size
            as argument and use it.

            * gcc.dg/torture/pr113831.c: New testcase.

    (cherry picked from commit c841144a94363ff26e40ab3f26b14702c32987a8)

Reply via email to