This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, x86] Fix pblendv expand.


On Wed, Dec 10, 2014 at 12:54 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Dec 10, 2014 at 12:33:52AM +0300, Evgeny Stupachenko wrote:
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/i386/blend.c
>> @@ -0,0 +1,61 @@
>> +/* Test correctness of size 3 store groups permutation.  */
>> +/* { dg-do run } */
>> +/* { dg-options "-O3" } */
>> +
>> +#define N 50
>> +
>> +enum num3
>> +{
>> +  a, b, c
>> +};
>> +
>> +struct flags
>> +{
>> +  enum num3 f;
>
> Does this really has to be an enum?  Doesn't unsigned int there work the
> same?

Without enum the loop is not vectorized because of cost model (scalar
code is 1 insn faster).
Anyway, even with "-fvect-cost-model=unlimited" the issue is not reproduced.

>
>> +int main()
>> +{
>> +  int i;
>> +  long long *rr = (long long *)q[0].a;
>> +  bar(2, q);
>> +  for (i = 0; i < N * 2; i += 2)
>> +    if (rr[i] == -1 && rr[i + 1] == -1)
>
> This is aliasing violation, can't you avoid that?  I mean, just
> check the individual struct flags fields?  And with the aliasing violation
> fixed, is there anything i?86 specific left in the testcase (i.e. shouldn't
> it go either to gcc.dg/ or gcc.c-torture/execute/ instead?)?

There is nothing i?86 specific. Not sure if it can give real value for
other architectures.
Let's move it to gcc.dg/vect

Updated patch:

2014-12-10  Evgeny Stupachenko  <evstupac@gmail.com>

gcc/testsuite
        * gcc.dg/vect/blend.c: New.

gcc/
        * config/i386/i386.c (expand_vec_perm_pblendv): Gen new rtx for
        expand_vec_perm_1 target.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index eafc15a..5a914ad 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -47546,6 +47546,7 @@ expand_vec_perm_pblendv (struct expand_vec_perm_d *d)
     dcopy.op0 = dcopy.op1 = d->op1;
   else
     dcopy.op0 = dcopy.op1 = d->op0;
+  dcopy.target = gen_reg_rtx (vmode);
   dcopy.one_operand_p = true;

   for (i = 0; i < nelt; ++i)
diff --git a/gcc/testsuite/gcc.dg/vect/blend.c
b/gcc/testsuite/gcc.dg/vect/blend.c
new file mode 100644
index 0000000..ebe2902
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/blend.c
@@ -0,0 +1,63 @@
+/* Test correctness of size 3 store groups permutation.  */
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+#define N 50
+
+enum num3
+{
+  a, b, c
+};
+
+struct flags
+{
+  enum num3 f;
+  unsigned int c;
+  unsigned int p;
+};
+
+struct flagsN
+{
+  struct flags a[N];
+};
+
+void
+bar (int n, struct flagsN *ff)
+{
+  struct flagsN *fc;
+  for (fc = ff + 1; fc < (ff + n); fc++)
+    {
+      int i;
+      for (i = 0; i < N; ++i)
+       {
+         ff->a[i].f = 0;
+         ff->a[i].c = i;
+         ff->a[i].p = -1;
+       }
+      for (i = 0; i < n; i++)
+       {
+         int j;
+         for (j = 0; j < N - n; ++j)
+           {
+             fc->a[i + j].f = 0;
+             fc->a[i + j].c = j + i;
+             fc->a[i + j].p = -1;
+           }
+       }
+    }
+}
+
+struct flagsN q[2];
+
+int main()
+{
+  int i;
+  check_vect ();
+  bar(2, q);
+  for (i = 0; i < N; i++)
+    if (q[0].a[i].f != 0 || q[0].a[i].c != i || q[0].a[i].p != -1)
+      return 1;
+  return 0;
+}
+/* { dg-final { cleanup-tree-dump "vect" } } */

>
>         Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]