public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/54703] New: [miscompilation] _mm_sub_pd is incorrectly substituted with vandnps
@ 2012-09-25 13:29 kretz at kde dot org
  2012-09-25 13:32 ` [Bug target/54703] " kretz at kde dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: kretz at kde dot org @ 2012-09-25 13:29 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54703
           Summary: [miscompilation] _mm_sub_pd is incorrectly substituted
                    with vandnps
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kretz@kde.org


The following testcase:

#include <xmmintrin.h>
__attribute__((aligned(16))) static const unsigned long long mask[2] = {
0xffffffffff000000ull, 0xffffffffff000000ull };
inline __m128d foo(__m128d v1) {
    const __m128d h1 = _mm_and_pd(v1, _mm_load_pd(reinterpret_cast<const double
*>(&mask)));
    const __m128d l1 = _mm_sub_pd(v1, h1);
    return _mm_mul_pd(h1, l1);
}
__m128d test() {
    __m128d a = _mm_set1_pd(2.);
    return foo(foo(a));
}

compiles to

        .cfi_startproc
        vmovaps _ZL4mask(%rip), %xmm0
        vandps  .LC0(%rip), %xmm0, %xmm2
        vandnps .LC0(%rip), %xmm0, %xmm1
        vmulpd  %xmm1, %xmm2, %xmm1
        vandps  %xmm0, %xmm1, %xmm0
        vsubpd  %xmm0, %xmm1, %xmm1
        vmulpd  %xmm1, %xmm0, %xmm0
        ret
        .cfi_endproc

The second foo call is correct: vandps and vsubpd are used. But the first call
uses vandps and vandnps. This pattern would be correct for integers, but is
obviously wrong for floating point numbers.


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

end of thread, other threads:[~2013-04-12 16:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-25 13:29 [Bug target/54703] New: [miscompilation] _mm_sub_pd is incorrectly substituted with vandnps kretz at kde dot org
2012-09-25 13:32 ` [Bug target/54703] " kretz at kde dot org
2012-09-25 13:48 ` [Bug target/54703] " rguenth at gcc dot gnu.org
2012-09-25 13:48 ` jakub at gcc dot gnu.org
2012-09-25 14:30 ` jakub at gcc dot gnu.org
2012-09-25 14:35 ` jakub at gcc dot gnu.org
2012-09-25 18:04 ` pinskia at gcc dot gnu.org
2012-09-25 21:57 ` jakub at gcc dot gnu.org
2012-09-26 10:53 ` kretz at kde dot org
2012-09-27 10:48 ` jakub at gcc dot gnu.org
2012-09-27 10:54 ` jakub at gcc dot gnu.org
2012-09-27 10:54 ` jakub at gcc dot gnu.org
2013-04-12 16:29 ` jakub 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).