This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, x86] Fix pblendv expand.
- From: Evgeny Stupachenko <evstupac at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, Uros Bizjak <ubizjak at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 10 Dec 2014 02:37:13 +0300
- Subject: Re: [PATCH, x86] Fix pblendv expand.
- Authentication-results: sourceware.org; auth=none
- References: <CAOvf_xxs3bOHcPCy_RyUQ7Tw=+KRodLZSidHgg7wPW=+WKi4qA at mail dot gmail dot com> <CAFULd4ZR3BG+QyxYZoceniFLHmxWoYUGh=WfCufNAVu8Pe1EmQ at mail dot gmail dot com> <CAFULd4ZFyyBnegJtUQkeVTOk-oPbO5LO_WQdsV2TBMYEh5cxJg at mail dot gmail dot com> <CAOvf_xzW3HWNhG6R6AzjS34ABySGaOFo+cM26P7ubEjUhN_YLw at mail dot gmail dot com> <CAOvf_xxkCnxx_VRpp6AgEfs1DYJ+NU0ebDZGicd4=MG29Dor9g at mail dot gmail dot com> <54872141 dot 3070102 at redhat dot com> <CAOvf_xw4UWkXXnCGsyTwhpvwtW1kMat+4NDhdHZAwgmGuFNXxw at mail dot gmail dot com> <CAOvf_xxPh=ROwvoYmmCrq4C2Q=YvQbUJ0xarV8ePs7fW8Gf11g at mail dot gmail dot com> <20141209215423 dot GU1667 at tucnak dot redhat dot com>
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