public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/66866] New: [miscompile] incorrect load address on manual vector shuffle
@ 2015-07-14 10:38 kretz at kde dot org
  2015-07-14 12:14 ` [Bug target/66866] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kretz at kde dot org @ 2015-07-14 10:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66866

            Bug ID: 66866
           Summary: [miscompile] incorrect load address on manual vector
                    shuffle
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kretz at kde dot org
  Target Milestone: ---

The following testcase fails at -O2:

#include <xmmintrin.h>
typedef short A __attribute__((__may_alias__));
short extr(const __m128i &d, int index) { return reinterpret_cast<const A
*>(&d)[index]; }
A &extr(__m128i &d, int index) { return reinterpret_cast<A *>(&d)[index]; }
__m128i shuf(const __m128i v)
{
  __m128i r;
  for (int i = 0; i + 4 <= 8; i += 4) {
    extr(r, i + 0) = extr(v, i + 1);
    extr(r, i + 1) = extr(v, i + 0);
    extr(r, i + 2) = extr(v, i + 3);
    extr(r, i + 3) = extr(v, i + 2);
  }
  return r;
}
int main()
{
  __attribute__((aligned(16))) short mem[8];
  *reinterpret_cast<__m128i *>(mem) = shuf(_mm_setr_epi16(0, 1, 2, 3, 4, 5, 6,
7));
  if (mem[0] == 1 && mem[1] == 0 && mem[2] == 3 && mem[3] == 2 && mem[4] == 5
&&
      mem[5] == 0 && mem[6] == 7 && mem[7] == 6) {
    abort();
  }
  return 0;
}

Here's a little survey:
for CXX in /opt/*/bin/{g++,clang++}; do echo -n "$CXX: "; $CXX -O2 testcase.cpp
&& ./a.out && echo passed || echo failed; done
/opt/gcc-4.5.2/bin/g++: passed
/opt/gcc-4.5.3/bin/g++: passed
/opt/gcc-4.5.4/bin/g++: passed
/opt/gcc-4.6.0/bin/g++: passed
/opt/gcc-4.6.1/bin/g++: passed
/opt/gcc-4.6.3/bin/g++: passed
/opt/gcc-4.7.0/bin/g++: failed
/opt/gcc-4.7.1/bin/g++: failed
/opt/gcc-4.7.2/bin/g++: failed
/opt/gcc-4.8.0/bin/g++: failed
/opt/gcc-4.8.2/bin/g++: failed
/opt/gcc-4.9.0/bin/g++: failed
/opt/gcc-4.9.1/bin/g++: failed
/opt/gcc-5.1.0/bin/g++: failed
/opt/gcc-6-snapshot/bin/g++: failed
/opt/clang-3.2/bin/clang++: passed
/opt/clang-3.3/bin/clang++: passed
/opt/clang-3.4/bin/clang++: passed
/opt/clang-3.5/bin/clang++: passed
/opt/clang-3.6/bin/clang++: passed
/opt/clang-master/bin/clang++: passed

The value at index 5 is assigned incorrectly from v[0] instead of v[4]. The
issue goes away if I manually unroll the loop.


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

end of thread, other threads:[~2015-07-17 21:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 10:38 [Bug target/66866] New: [miscompile] incorrect load address on manual vector shuffle kretz at kde dot org
2015-07-14 12:14 ` [Bug target/66866] " rguenth at gcc dot gnu.org
2015-07-14 12:26 ` rguenth at gcc dot gnu.org
2015-07-14 12:45 ` rguenth at gcc dot gnu.org
2015-07-14 12:47 ` rguenth at gcc dot gnu.org
2015-07-14 12:51 ` rguenth at gcc dot gnu.org
2015-07-15  9:05 ` ubizjak at gmail dot com
2015-07-15 22:20 ` uros at gcc dot gnu.org
2015-07-15 22:23 ` [Bug target/66866] [4.9/5 Regression] " ubizjak at gmail dot com
2015-07-17 20:25 ` uros at gcc dot gnu.org
2015-07-17 21:40 ` uros at gcc dot gnu.org
2015-07-17 21:41 ` ubizjak at gmail dot com

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