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

--- Comment #23 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>:

https://gcc.gnu.org/g:2111d5406a4ec56d6335bde779a995914d0a36d1

commit r10-7657-g2111d5406a4ec56d6335bde779a995914d0a36d1
Author: Martin Jambor <mjam...@suse.cz>
Date:   Thu Apr 9 14:37:21 2020 +0200

    sra: Fix sra_modify_expr handling of partial writes (PR 94482)

    when sra_modify_expr is invoked on an expression that modifies only
    part of the underlying replacement, such as a BIT_FIELD_REF on a LHS
    of an assignment and the SRA replacement's type is not compatible with
    what is being replaced (0th operand of the B_F_R in the above
    example), it does not work properly, basically throwing away the partd
    of the expr that should have stayed intact.

    This is fixed in two ways.  For BIT_FIELD_REFs, which operate on the
    binary image of the replacement (and so in a way serve as a
    VIEW_CONVERT_EXPR) we just do not bother with convertsing.  For
    REALPART_EXPRs and IMAGPART_EXPRs, if the replacement is not a
    register, we insert a VIEW_CONVERT_EXPR under
    the complex partial access expression, which is always OK, for loads
    from registers we take the extra step of converting it to a temporary.

    This revealed a bug in fwprop which is fixed with the hunk from Richi.

    The testcase for handling REALPART_EXPR and IMAGPART_EXPR is a bit
    fragile because SRA prefers complex and vector types over anything
    else (and in between the two it decides based on TYPE_UID which in my
    testing today always preferred complex types) and so I only run it at
    -O1 (which is the only level where the the test fails for me).

    Bootstrapped and tested on x86_64-linux, i686-linux and aarch64-linux.

    2020-04-09  Martin Jambor  <mjam...@suse.cz>
                Richard Biener  <rguent...@suse.de>

            PR tree-optimization/94482
            * tree-sra.c (create_access_replacement): Dump new replacement with
            TDF_UID.
            (sra_modify_expr): Fix handling of cases when the original EXPR
writes
            to only part of the replacement.
            * tree-ssa-forwprop.c (pass_forwprop::execute): Properly verify
            the first operand of combinations into REAL/IMAGPART_EXPR and
            BIT_FIELD_REF.

            testsuite/
            * gcc.dg/torture/pr94482.c: New test.
            * gcc.dg/tree-ssa/pr94482-2.c: Likewise.

Reply via email to