This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix result for conditional reductions matching at index 0
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Kilian Verhetsel <kilian dot verhetsel at uclouvain dot be>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Alan Hayward <Alan dot Hayward at arm dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Mon, 11 Dec 2017 18:06:03 +0100
- Subject: Re: [PATCH] Fix result for conditional reductions matching at index 0
- Authentication-results: sourceware.org; auth=none
- References: <87zi7fbn07.fsf@uclouvain.be> <CAFiYyc2GcuaKcD8XgfT0XkFd=gCRFiaM=eHMXFTK1P1Ct4rWzw@mail.gmail.com> <E4166ABC-97D0-4A48-B1C6-5EAB06CC1979@arm.com> <CAFiYyc2jzbC4x-h=+8ksNz4Oc90U4XMqrhqNHnwf+Tj=84Vckg@mail.gmail.com> <87wp2ib6aj.fsf@uclouvain.be> <20171208181501.GB2353@tucnak> <87po7lleh4.fsf@uclouvain.be> <20171211131134.GL2353@tucnak> <20171211135150.GM2353@tucnak> <87o9n5kxno.fsf@uclouvain.be>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Dec 11, 2017 at 06:00:11PM +0100, Kilian Verhetsel wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
> > Of course it can be done efficiently, what we care most is that the body of
> > the vectorized loop is efficient.
>
> That's fair, I was looking at the x86 assembly being generated when a single
> vectorized iteration was enough (because that is the context in which I
> first encountered this bug):
>
> int f(unsigned int *x, unsigned int k) {
> unsigned int result = 8;
> for (unsigned int i = 0; i < 8; i++) {
> if (x[i] == k) result = i;
> }
> return result;
> }
>
> where the vpand instruction this generates would have to be replaced
> with a variable blend if the default value weren't 0 — although I had
> not realized even SSE4.1 on x86 includes such an instruction, making
> this point less relevant.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80631#c6 where I've
attached so far untested prototype. If it is added before your patch
makes it in, your patch would start by introducing another kind
(say SIMPLE_INTEGER_INDUC_COND_REDUCTION) and would use that for the
spots that are handled by the PR80631 patch as INTEGER_INDUC_COND_REDUCTION
right now and your code for the rest. E.g. the above testcase with my
patch, because i is unsigned and base is the minimum of the type is emitted as
COND_REDUCTION, which is what your patch would improve.
> > Another thing is, as your patch is quite large, we need a copyright
> > assignment for the changes before we can accept it, see
> > https://gcc.gnu.org/contribute.html for details.
> >
> > If you are already covered by an assignment of some company, please tell
> > us which one it is, otherwise contact us and we'll get you the needed
> > forms.
>
> I am not covered by any copyright assignment yet. Do I need to send you
> any additional information?
I'll send it offlist.
Jakub