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

            Bug ID: 69551
           Summary: Wrong code with single element vector insert
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---
            Target: x86

Following testcase aborts when compiled with "-O2 -msse -mno-sse2":

--cut here--
typedef unsigned char v16qi __attribute__ ((vector_size (16)));
typedef unsigned int v4si __attribute__ ((vector_size (16)));

char __attribute__((noinline, noclone))
test (v4si vec)
{
  vec[1] = 0x5fb856;

  return ((v16qi) vec)[0];
}

int
main ()
{
  char z = test ( (v4si) {-1, -1, -1, -1} );

  if (z != -1)
    __builtin_abort ();
  return 0;
}
--cut here--

$ ~/gcc-build/gcc/xgcc -B ~/gcc-build/gcc/ -O2 -msse -mno-sse2 -m32 tt.c 
$ ./a.out
Aborted

The test function expands to following RTL:

    1: NOTE_INSN_DELETED
    4: NOTE_INSN_BASIC_BLOCK 2
    2: r91:V4SI=xmm0:V4SI
    3: NOTE_INSN_FUNCTION_BEG
    6: r92:SI=0x5fb856
    7: r94:V4SF=r93:V4SF
    8: r93:V4SF=vec_select(vec_concat(r93:V4SF,r93:V4SF),parallel)
    9: r93:V4SF=vec_merge(vec_duplicate(r92:SI#0),r93:V4SF,0x1)
   10: r93:V4SF=vec_select(vec_concat(r93:V4SF,r94:V4SF),parallel)
   11: r91:V4SI=r93:V4SF#0
   12: r96:SI#0=vec_select(r91:V4SI#0,parallel)
   13: r90:QI=r96:SI#0
   17: ax:QI=r90:QI
   18: use ax:QI

which is already wrong. r91, used to pass argument is not used anywhere.

Reply via email to