From: Bill Schmidt <wschmidt@linux.vnet.ibm.com>
To: Alan Lawrence <alan.lawrence@arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
"dje.gcc@gmail.com" <dje.gcc@gmail.com>,
rguenther@suse.de, alan.hayward@arm.com,
ramana.gcc@googlemail.com
Subject: Re: [PATCH, rs6000] Add expansions for min/max vector reductions
Date: Wed, 16 Sep 2015 16:14:00 -0000 [thread overview]
Message-ID: <1442419857.10907.0.camel@gnopaine> (raw)
In-Reply-To: <55F98AD2.4080408@arm.com>
On Wed, 2015-09-16 at 16:29 +0100, Alan Lawrence wrote:
> On 16/09/15 15:28, Bill Schmidt wrote:
> > 2015-09-16 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
> >
> > * config/rs6000/altivec.md (UNSPEC_REDUC_SMAX, UNSPEC_REDUC_SMIN,
> > UNSPEC_REDUC_UMAX, UNSPEC_REDUC_UMIN, UNSPEC_REDUC_SMAX_SCAL,
> > UNSPEC_REDUC_SMIN_SCAL, UNSPEC_REDUC_UMAX_SCAL,
> > UNSPEC_REDUC_UMIN_SCAL): New enumerated constants.
> > (reduc_smax_v2di): New define_expand.
> > (reduc_smax_scal_v2di): Likewise.
> > (reduc_smin_v2di): Likewise.
> > (reduc_smin_scal_v2di): Likewise.
> > (reduc_umax_v2di): Likewise.
> > (reduc_umax_scal_v2di): Likewise.
> > (reduc_umin_v2di): Likewise.
> > (reduc_umin_scal_v2di): Likewise.
> > (reduc_smax_v4si): Likewise.
> > (reduc_smin_v4si): Likewise.
> > (reduc_umax_v4si): Likewise.
> > (reduc_umin_v4si): Likewise.
> > (reduc_smax_v8hi): Likewise.
> > (reduc_smin_v8hi): Likewise.
> > (reduc_umax_v8hi): Likewise.
> > (reduc_umin_v8hi): Likewise.
> > (reduc_smax_v16qi): Likewise.
> > (reduc_smin_v16qi): Likewise.
> > (reduc_umax_v16qi): Likewise.
> > (reduc_umin_v16qi): Likewise.
> > (reduc_smax_scal_<mode>): Likewise.
> > (reduc_smin_scal_<mode>): Likewise.
> > (reduc_umax_scal_<mode>): Likewise.
> > (reduc_umin_scal_<mode>): Likewise.
>
> You shouldn't need the non-_scal reductions. Indeed, they shouldn't be used if
> the _scal are present. The non-_scal's were previously defined as producing a
> vector with one element holding the result and the other elements all zero, and
> this was only ever used with a vec_extract immediately after; the _scal pattern
> now includes the vec_extract as well. Hence the non-_scal patterns are
> deprecated / considered legacy, as per md.texi.
Thanks -- I had misread the description of the non-scalar versions,
missing the part where the other elements are zero. What I really
want/need is an optab defined as computing the maximum value in all
elements of the vector. This seems like a strange thing to want, but
Alan Hayward's proposed patch will cause us to generate the scalar
version, followed by a broadcast of the vector. Since our patterns
already generate the maximum value in all positions, this creates an
unnecessary extract followed by an unnecessary broadcast.
As discussed elsewhere, we *could* remove the unnecessary code by
recognizing this in simplify-rtx, etc., but the vectorization cost
modeling would be wrong. It would have still told us to model this as a
vec_to_scalar for the reduc_max_scal, and a vec_stmt for the broadcast.
This would overcount the cost of the reduction compared to what we would
actually generate.
To get this right for all targets, one could envision having a new optab
for a reduction-to-vector, which most targets wouldn't implement, but
PowerPC and AArch32, at least, would. If a target has a
reduction-to-vector, the vectorizer would have to generate a different
GIMPLE code that mapped to this; otherwise it would do the
REDUC_MAX_EXPR and the broadcast. This obviously starts to get
complicated, since adding a GIMPLE code certainly has a nontrivial
cost. :/
Perhaps the practical thing is to have the vectorizer also do an
add_stmt_cost with some new token that indicates the cost model should
make an adjustment if the back end doesn't need the extract/broadcast.
Targets like PowerPC and AArch32 could then subtract the unnecessary
cost, and remove the unnecessary code in simplify-rtx.
Copying Richi and ARM folks for opinions on the best design. I want to
be able to model this stuff as accurately as possible, but obviously we
need to avoid unnecessary effects on other architectures.
In any case, I will remove implementing the deprecated optabs, and I'll
also try to look at Alan L's patch shortly.
Thanks,
Bill
>
> I proposed a patch to migrate PPC off the old patterns, but have forgotten to
> ping it recently - last at
> https://gcc.gnu.org/ml/gcc-patches/2014-12/msg01024.html ... (ping?!)
>
> --Alan
>
next prev parent reply other threads:[~2015-09-16 16:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 14:28 Bill Schmidt
2015-09-16 14:36 ` David Edelsohn
2015-09-16 14:42 ` Ramana Radhakrishnan
2015-09-16 15:15 ` Bill Schmidt
2015-09-16 15:29 ` Segher Boessenkool
2015-09-16 15:29 ` Bill Schmidt
2015-09-16 15:41 ` Alan Lawrence
2015-09-16 16:14 ` Bill Schmidt [this message]
2015-09-16 17:09 ` Alan Lawrence
2015-09-16 22:04 ` Bill Schmidt
2015-09-17 7:47 ` Richard Biener
2015-09-17 14:28 ` Bill Schmidt
2015-09-17 16:32 ` Bill Schmidt
2015-09-18 8:36 ` Richard Biener
2015-09-18 15:44 ` Alan Lawrence
2015-09-17 19:08 ` Segher Boessenkool
2015-09-18 8:39 ` Richard Biener
2015-09-18 13:15 ` Bill Schmidt
2015-09-18 13:21 ` Richard Biener
2015-09-18 13:54 ` Bill Schmidt
2015-09-16 16:25 ` Bill Schmidt
2015-09-16 18:26 ` Alan Lawrence
2015-09-16 18:37 ` Bill Schmidt
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=1442419857.10907.0.camel@gnopaine \
--to=wschmidt@linux.vnet.ibm.com \
--cc=alan.hayward@arm.com \
--cc=alan.lawrence@arm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ramana.gcc@googlemail.com \
--cc=rguenther@suse.de \
/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).