From: Richard Biener <richard.guenther@gmail.com>
To: Roger Sayle <roger@nextmovesoftware.com>,
Richard Sandiford <richard.sandiford@arm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Simplify vec_unpack of uniform_vector_p constructors in match.pd.
Date: Mon, 23 May 2022 12:49:39 +0200 [thread overview]
Message-ID: <CAFiYyc30acCdPVCW_WqFym3fTYSeABn6ydPvLOnsd5WiUMHfmA@mail.gmail.com> (raw)
In-Reply-To: <008401d86d27$d74f9a20$85eece60$@nextmovesoftware.com>
On Sat, May 21, 2022 at 5:31 PM Roger Sayle <roger@nextmovesoftware.com> wrote:
>
>
> This patch simplifies vec_unpack_hi_expr/vec_unpack_lo_expr of a uniform
> constructor or vec_duplicate operand. The motivation is from PR 105621
> where after optimization, we're left with:
>
> vect_cst__21 = {c_8(D), c_8(D), c_8(D), c_8(D)};
> vect_iftmp.7_4 = [vec_unpack_hi_expr] vect_cst__21;
>
> It turns out that there are no constant folding/simplification patterns
> in match.pd, but the above can be simplified further to the equivalent:
>
> _20 = (long int) c_8(D);
> vect_iftmp.7_4 = [vec_duplicate_expr] _20;
>
> which on x86-64 results in one less instruction, replacing pshufd $0
> then punpackhq, with punpcklqdq. This transformation is also useful
> for helping CSE to spot that unpack_hi and unpack_lo are equivalent.
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check with no new failures. Ok for mainline?
I think we need a way to query whether the target can do a VEC_DUPLICATE_EXPR.
Currently we only ever have them for VL vectors and expand via
expand_vector_broadcast which eventually simply gives up when there's no
vec_duplicate or vec_init optabs suitable.
IIRC with the VEC_PERM extension we should be able to handle
VEC_DUPLICATE via VEC_PERM? (but we don't yet accept a scalar
input, just V1<mode>?)
I see most targets have picked up vec_duplicate but sparc, but still
we'd need to check the specific mode. I think we can disregart
vec_init checking and only apply the transforms when vec_duplicate
is available.
Richard.
>
> 2022-05-21 Roger Sayle <roger@nextmovesoftware.com>
>
> gcc/ChangeLog
> * match.pd (simplify vec_unpack_hi): Simplify VEC_UNPACK_*_EXPR
> of uniform vector constructors and vec_duplicate.
>
> gcc/testsuite/ChangeLog
> * g++.dg/vect/pr105621.cc: New test case.
>
>
> Thanks in advance,
> Roger
> --
>
next prev parent reply other threads:[~2022-05-23 10:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-21 15:31 Roger Sayle
2022-05-23 10:49 ` Richard Biener [this message]
2022-06-06 9:06 ` Richard Sandiford
2022-06-13 9:52 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFiYyc30acCdPVCW_WqFym3fTYSeABn6ydPvLOnsd5WiUMHfmA@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.sandiford@arm.com \
--cc=roger@nextmovesoftware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).