public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55590] New: SRA still produces unnecessarily unaligned memory accesses
@ 2012-12-04 10:35 jamborm at gcc dot gnu.org
  2012-12-05 15:18 ` [Bug tree-optimization/55590] " jamborm at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jamborm at gcc dot gnu.org @ 2012-12-04 10:35 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55590

             Bug #: 55590
           Summary: SRA still produces unnecessarily unaligned memory
                    accesses
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: jamborm@gcc.gnu.org
        ReportedBy: jamborm@gcc.gnu.org


SRA can still produce unaligned memory accesses which should be
aligned when it's basing its new scalar access on a MEM_REF buried
below COMPONENT_REFs or ARRAY_REFs.

Testcase 1:

/* { dg-do compile } */
/* { dg-options "-O2 -mavx" } */

#include <immintrin.h>

struct S
{
  __m128 a, b;
};

struct T
{
  int a;
  struct S s;
};

void foo (struct T *p, __m128 v)
{
  struct S s;

  s = p->s;
  s.b = _mm_add_ps(s.b, v);
  p->s = s;
}

/* { dg-final { scan-assembler-not "vmovups" } } */

on x86_64 compiles to

        vmovups 32(%rdi), %xmm1
        vaddps  %xmm0, %xmm1, %xmm0
        vmovups %xmm0, 32(%rdi)

even though it should really be

        vaddps  32(%rdi), %xmm0, %xmm0
        vmovaps %xmm0, 32(%rdi)
        ret



Testcase 2 (which describes why this should be fixed differently from
the recent IPA-SRA patch because of the variable array index):

/* { dg-do compile } */
/* { dg-options "-O2 -mavx" } */

#include <immintrin.h>

struct S
{
  __m128 a, b;
};

struct T
{
  int a;
  struct S s[8];
};

void foo (struct T *p, int i, __m128 v)
{
  struct S s;

  s = p->s[i];
  s.b = _mm_add_ps(s.b, v);
  p->s[i] = s;
}

/* { dg-final { scan-assembler-not "vmovups" } } */

Compiles to

        movslq  %esi, %rsi
        salq    $5, %rsi
        leaq    16(%rdi,%rsi), %rax
        vmovups 16(%rax), %xmm1
        vaddps  %xmm0, %xmm1, %xmm0
        vmovups %xmm0, 16(%rax)
        ret

when it should produce

        movslq  %esi, %rsi
        salq    $5, %rsi
        leaq    16(%rdi,%rsi), %rax
        vaddps  16(%rax), %xmm0, %xmm0
        vmovaps %xmm0, 16(%rax)
        ret

I'm testing a patch.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/55590] SRA still produces unnecessarily unaligned memory accesses
  2012-12-04 10:35 [Bug tree-optimization/55590] New: SRA still produces unnecessarily unaligned memory accesses jamborm at gcc dot gnu.org
@ 2012-12-05 15:18 ` jamborm at gcc dot gnu.org
  2012-12-07 12:51 ` jamborm at gcc dot gnu.org
  2012-12-07 13:08 ` jamborm at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jamborm at gcc dot gnu.org @ 2012-12-05 15:18 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55590

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-p
                   |                            |atches/2012-12/msg00237.htm
                   |                            |l

--- Comment #1 from Martin Jambor <jamborm at gcc dot gnu.org> 2012-12-05 15:17:29 UTC ---
I have submitted the patch to the mailing list:

http://gcc.gnu.org/ml/gcc-patches/2012-12/msg00237.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/55590] SRA still produces unnecessarily unaligned memory accesses
  2012-12-04 10:35 [Bug tree-optimization/55590] New: SRA still produces unnecessarily unaligned memory accesses jamborm at gcc dot gnu.org
  2012-12-05 15:18 ` [Bug tree-optimization/55590] " jamborm at gcc dot gnu.org
@ 2012-12-07 12:51 ` jamborm at gcc dot gnu.org
  2012-12-07 13:08 ` jamborm at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jamborm at gcc dot gnu.org @ 2012-12-07 12:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55590

--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> 2012-12-07 12:50:46 UTC ---
Author: jamborm
Date: Fri Dec  7 12:50:43 2012
New Revision: 194300

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194300
Log:
2012-12-07  Martin Jambor  <mjambor@suse.cz>

    PR tree-optimization/55590
    * tree-sra.c (build_ref_for_offset): Use get_object_alignment_1 to
    get base alignment.

    * testsuite/gcc.target/i386/pr55590-1.c: New test.
    * testsuite/gcc.target/i386/pr55590-2.c: Likewise.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr55590-1.c
    trunk/gcc/testsuite/gcc.target/i386/pr55590-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/55590] SRA still produces unnecessarily unaligned memory accesses
  2012-12-04 10:35 [Bug tree-optimization/55590] New: SRA still produces unnecessarily unaligned memory accesses jamborm at gcc dot gnu.org
  2012-12-05 15:18 ` [Bug tree-optimization/55590] " jamborm at gcc dot gnu.org
  2012-12-07 12:51 ` jamborm at gcc dot gnu.org
@ 2012-12-07 13:08 ` jamborm at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jamborm at gcc dot gnu.org @ 2012-12-07 13:08 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55590

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Martin Jambor <jamborm at gcc dot gnu.org> 2012-12-07 13:07:56 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-07 13:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-04 10:35 [Bug tree-optimization/55590] New: SRA still produces unnecessarily unaligned memory accesses jamborm at gcc dot gnu.org
2012-12-05 15:18 ` [Bug tree-optimization/55590] " jamborm at gcc dot gnu.org
2012-12-07 12:51 ` jamborm at gcc dot gnu.org
2012-12-07 13:08 ` jamborm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).