Patchwork 4.4/4.5 PATCH: PR middle-end/45678: [4.4/4.5/4.6 Regression] crash on vector code with -m32 -msse

login
register
mail settings
Submitter Richard Guenther
Date Sept. 21, 2010, 9:42 a.m.
Message ID <AANLkTin4qCWUqv0c8Ornn97mvYSmkQMh4yBr4RWGviWG@mail.gmail.com>
Download mbox | patch
Permalink /patch/65288/
State New
Headers show

Comments

Richard Guenther - Sept. 21, 2010, 9:42 a.m.
On Tue, Sep 21, 2010 at 1:45 AM, H.J. Lu <hjl.tools@gmail.com> 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  <hongjiu.lu@intel.com>
>
>        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  <jakub@redhat.com>
>
>        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  <hongjiu.lu@intel.com>
>
>        Backport from mainline
>        2010-09-17  Richard Guenther  <rguenther@suse.de>
>                    H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR middle-end/45678
>        * gcc.dg/torture/pr45678-1.c: New.
>        * gcc.dg/torture/pr45678-2.c: Likewise.
>

Patch

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))