public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/55448] New: using const-reference SSE or AVX types leads to unnecessary unaligned loads
@ 2012-11-23 15:15 kretz at kde dot org
  2012-11-23 17:28 ` [Bug target/55448] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: kretz at kde dot org @ 2012-11-23 15:15 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55448
           Summary: using const-reference SSE or AVX types leads to
                    unnecessary unaligned loads
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kretz@kde.org


The following testcase:

#include <immintrin.h>
static inline __m256 add(const __m256 &a, const __m256 &b) { return
_mm256_add_ps(a, b); }
void foo(__m256 &a, const __m256 b) { a = add(a, b); }

static inline __m128 add(const __m128 &a, const __m128 &b) { return
_mm_add_ps(a, b); }
void foo(__m128 &a, const __m128 b) { a = add(a, b); }

compiled with "-O2 -mavx"

lead to
        vmovups (%rdi), %xmm1
        vinsertf128     $0x1, 16(%rdi), %ymm1, %ymm1
        vaddps  %ymm0, %ymm1, %ymm0
        vmovaps %ymm0, (%rdi)

for the __m256 case and

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

for the __m128 case.

It should rather be:
        vaddps  (%rdi), %ymm0, %ymm0
        vmovaps %ymm0, (%rdi)
and:
        vaddps  (%rdi), %xmm0, %xmm0
        vmovaps %xmm0, (%rdi)

The latter result can be obtained if the const-ref arguments to add are changed
to pass by value.


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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-23 15:15 [Bug target/55448] New: using const-reference SSE or AVX types leads to unnecessary unaligned loads kretz at kde dot org
2012-11-23 17:28 ` [Bug target/55448] " jakub at gcc dot gnu.org
2012-11-23 17:51 ` jakub at gcc dot gnu.org
2012-11-24 21:38 ` kretz at kde dot org
2012-11-27 20:46 ` jamborm at gcc dot gnu.org
2012-11-30 16:12 ` jamborm at gcc dot gnu.org
2012-12-03 13:29 ` 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).