From patchwork Tue Dec 9 23:37:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Stupachenko X-Patchwork-Id: 419335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B36C614009B for ; Wed, 10 Dec 2014 10:37:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=hMj0BOviV4Y9onR2J1 BlkwFmXwnDJijhEfuGuLfRpixF3w+Jl5w2icRUWxG6g0/CVdHAytS9bAQdmA5MxN 8Pyc4rHPlGOemhKw6w2q1IVE30cwJuJ7+4cZ5Jp4iI2vGRQ1GtBGsnl0dKEGxmB2 h4FCZKcWBJJtakAo9D5fasR78= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=qtnOg7pdozphy6oyDu6PAASL FWs=; b=Cek6qTz1xPpFM7dsQquSrT6641OB7UCMztDWz1Ay2jdNFIJ88d0sw+02 xzwPxuGSTtz5y8wkSDD8vUmPbxr2kBpJDhUkAxti9rtkUj0ZRmfZ/cIm5H/iMkkh T3fXUkLZ0ed9tiwtF3jxVcOpO2VleMJlloTbOI4sTWBHldp/rJI= Received: (qmail 5525 invoked by alias); 9 Dec 2014 23:37:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 5511 invoked by uid 89); 9 Dec 2014 23:37:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f176.google.com Received: from mail-ig0-f176.google.com (HELO mail-ig0-f176.google.com) (209.85.213.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 09 Dec 2014 23:37:24 +0000 Received: by mail-ig0-f176.google.com with SMTP id l13so5854217iga.15 for ; Tue, 09 Dec 2014 15:37:21 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.50.61.140 with SMTP id p12mr5203018igr.34.1418168233117; Tue, 09 Dec 2014 15:37:13 -0800 (PST) Received: by 10.107.135.82 with HTTP; Tue, 9 Dec 2014 15:37:13 -0800 (PST) In-Reply-To: <20141209215423.GU1667@tucnak.redhat.com> References: <54872141.3070102@redhat.com> <20141209215423.GU1667@tucnak.redhat.com> Date: Wed, 10 Dec 2014 02:37:13 +0300 Message-ID: Subject: Re: [PATCH, x86] Fix pblendv expand. From: Evgeny Stupachenko To: Jakub Jelinek Cc: Richard Henderson , Uros Bizjak , GCC Patches X-IsSubscribed: yes On Wed, Dec 10, 2014 at 12:54 AM, Jakub Jelinek 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 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. > > Jakub 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" } } */