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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-17 
08:45:40 UTC ---
Slightly more reduced:

struct T { float r[3], i[3]; };
struct U { struct T j[2]; };

void __attribute__ ((noinline))
foo (struct U *__restrict y, const float _Complex *__restrict x)
{
  int i, j;
  for (j = 0; j < 2; ++j)
    {
      float a = __real__ x[j];
      float b = __imag__ x[j];
      float c = __real__ x[j + 2];
      float d = __imag__ x[j + 2];
      for (i = 0; i < 3; ++i)
        {
          y->j[j].r[i] = y->j[j].r[i] + a + c;
          y->j[j].i[i] = y->j[j].i[i] + b + d;
        }
    }
}

_Complex float x[4];
struct U y;

int
main ()
{
  int i, j;
  for (i = 0; i < 4; ++i)
    x[i] = i + 1.0iF * (2 * i);
  foo (&y, x);
  for (j = 0; j < 2; ++j)
    for (i = 0; i < 3; ++i)
      if (y.j[j].r[i] != __real__ (x[j] + x[j + 2])
          || y.j[j].i[i] != __imag__ (x[j] + x[j + 2]))
        __builtin_abort ();
  return 0;
}

I bet the bug is in vect_supported_load_permutation_p, in particular the
complex_numbers == 2 handling there.
The if (complex_numbers) doesn't do anything, because
GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == first in all cases,
and then just
  /* We checked that this case ok, so there is no need to proceed with 
     permutation tests.  */
  if (complex_numbers == 2)
    {
      VEC_free (slp_tree, heap, SLP_INSTANCE_LOADS (slp_instn));
      VEC_free (int, heap, SLP_INSTANCE_LOAD_PERMUTATION (slp_instn));
      return true;
    }
I guess we need way more checks than that to verify we don't need to proceed
with permutation tests.  E.g. one possible reason not to return early might be
that complex_numbers != VEC_length (slp_tree, SLP_INSTANCE_LOADS (slp_instn)) ?
In that case we fail to check altogether whether the non-complex permutations
match the complex ones.  I also wonder whether group lengths smaller than
group_size can't be a problem (in this case, group_size is 6, but the complex
groups have just 2 elements).  This stuff has been added as part of the PR44152
fix.

Reply via email to