https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94482
--- Comment #27 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>: https://gcc.gnu.org/g:9300be2c74e35709ded209a378edab91a9073fbc commit r9-8520-g9300be2c74e35709ded209a378edab91a9073fbc Author: Martin Jambor <mjam...@suse.cz> Date: Tue Apr 21 14:20:37 2020 +0200 sra-9: Fix sra_modify_expr handling of partial writes (PR 94482) This is a fairly straightforward backport of the mainline fix for 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 part 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 converting. 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. This is the only difference from the mainline patch which has two hunks, but the code handling BIT_FIELD_REF is not present in gcc-9. Oh, and the testcase options were changed to what Jakub put there on the mainline to suppress all vector ABI warnings. Bootstrapped and tested on x86_64-linux. 2020-04-21 Martin Jambor <mjam...@suse.cz> Backport from master 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.