From patchwork Tue Sep 21 09:42:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: 4.4/4.5 PATCH: PR middle-end/45678: [4.4/4.5/4.6 Regression] crash on vector code with -m32 -msse Date: Mon, 20 Sep 2010 23:42:42 -0000 From: Richard Guenther X-Patchwork-Id: 65288 Message-Id: To: "H.J. Lu" Cc: Richard Henderson , Jakub Jelinek , gcc-patches@gcc.gnu.org On Tue, Sep 21, 2010 at 1:45 AM, H.J. Lu wrote: > Here is the patch for 4.4/4.5. fold_builtin_memory_op is very different > in 4.4/4.5.  Simple backport doesn't work.  Does this patch make > any senses? No, checking alignment that way doesn't make sense. You're likely just papering over the problem. The alignment check is bogus anyway as get_pointer_alignment will at least return TYPE_ALIGN ({dest,src}type). There's a lot of latent issues with memcpy folding for strict-alignment targets on the branch (and that includes SSE modes which make x86 strict-alignment as well). I'm not sure it's worth fixing there. You could try to do The problem is that src_align and dest_align are completely bogus estimates. Richard. > Thanks. > > > -- > H.J. > -- > gcc/ > > 2010-09-20  H.J. Lu   > >        PR middle-end/45678 >        * builtins.c (fold_builtin_memory_op): Return NULL_TREE if >        dest alignment > src alignment. > >        Backport from mainline >        2010-09-20  Jakub Jelinek   > >        PR middle-end/45678 >        * cfgexpand.c (expand_one_stack_var_at): Limit alignment to >        crtl->max_used_stack_slot_alignment. > > gcc/testsuite/ > > 2010-09-20  H.J. Lu   > >        Backport from mainline >        2010-09-17  Richard Guenther   >                    H.J. Lu   > >        PR middle-end/45678 >        * gcc.dg/torture/pr45678-1.c: New. >        * gcc.dg/torture/pr45678-2.c: Likewise. > Index: builtins.c =================================================================== --- builtins.c (revision 164429) +++ builtins.c (working copy) @@ -8373,7 +8373,8 @@ fold_builtin_memory_op (location_t loc, return NULL_TREE; srctype = build_qualified_type (desttype, 0); - if (src_align < (int) TYPE_ALIGN (srctype)) + if (src_align < (int) TYPE_ALIGN (srctype) + || GET_MODE_BITSIZE (TYPE_MODE (srctype)) > BITS_PER_WORD) { if (AGGREGATE_TYPE_P (srctype) || SLOW_UNALIGNED_ACCESS (TYPE_MODE (srctype), src_align)) @@ -8395,7 +8396,8 @@ fold_builtin_memory_op (location_t loc, return NULL_TREE; desttype = build_qualified_type (srctype, 0); - if (dest_align < (int) TYPE_ALIGN (desttype)) + if (dest_align < (int) TYPE_ALIGN (desttype) + || GET_MODE_BITSIZE (TYPE_MODE (desttype)) > BITS_PER_WORD) { if (AGGREGATE_TYPE_P (desttype) || SLOW_UNALIGNED_ACCESS (TYPE_MODE (desttype), dest_align))