Hi, this fixes an oversight in r274986. We need to avoid using movmisalign on DECL_P which are not in memory, similar to the !mem_ref_refers_to_non_mem_p which unfortunately can't handle DECL_P.
Bootstrapped and reg-tested on x86_64-pc-linux-gnu. Is it OK for trunk? Thanks Bernd.
2019-09-01 Bernd Edlinger <bernd.edlin...@hotmail.de> PR middle-end/91605 * expr.c (expand_assignment): Avoid DECL_P with DECL_RTL not being MEM_P. testsuite: 2019-09-01 Bernd Edlinger <bernd.edlin...@hotmail.de> PR middle-end/91605 * g++.target/i386/pr91605.C: New test. Index: gcc/expr.c =================================================================== --- gcc/expr.c (revision 275063) +++ gcc/expr.c (working copy) @@ -5004,7 +5004,8 @@ expand_assignment (tree to, tree from, bool nontem || TREE_CODE (to) == TARGET_MEM_REF || DECL_P (to)) && mode != BLKmode - && (DECL_P (to) || !mem_ref_refers_to_non_mem_p (to)) + && (DECL_P (to) ? MEM_P (DECL_RTL (to)) + : !mem_ref_refers_to_non_mem_p (to)) && ((align = get_object_alignment (to)) < GET_MODE_ALIGNMENT (mode)) && (((icode = optab_handler (movmisalign_optab, mode)) Index: gcc/testsuite/g++.target/i386/pr91605.C =================================================================== --- gcc/testsuite/g++.target/i386/pr91605.C (revision 0) +++ gcc/testsuite/g++.target/i386/pr91605.C (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fpack-struct -mavx" } */ + +struct A { + __attribute__((__vector_size__(4 * sizeof(double)))) double data; +}; +struct B { + A operator*(B); +}; +void fn1() { + B x, y; + x *y; +}