This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR60505
- From: Richard Biener <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Cong Hou <congh at google dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 12 Mar 2014 10:05:17 +0100 (CET)
- Subject: Re: [PATCH] Fix PR60505
- Authentication-results: sourceware.org; auth=none
- References: <CAK=A3=1eySj3DAFV+3=GSD6y9KxnMQ6SKUW9s43cybRN7PeBiw at mail dot gmail dot com> <20140312082459 dot GI22862 at tucnak dot redhat dot com>
On Wed, 12 Mar 2014, Jakub Jelinek wrote:
> On Tue, Mar 11, 2014 at 04:16:13PM -0700, Cong Hou wrote:
> > This patch is fixing PR60505 in which the vectorizer may produce
> > unnecessary epilogues.
> >
> > Bootstrapped and tested on a x86_64 machine.
> >
> > OK for trunk?
>
> That looks wrong. Consider the case where the loop isn't versioned,
> if you disable generation of the epilogue loop, you end up only with
> a vector loop.
>
> Say:
> unsigned char ovec[16] __attribute__((aligned (16))) = { 0 };
> void
> foo (char *__restrict in, char *__restrict out, int num)
> {
> int i;
>
> in = __builtin_assume_aligned (in, 16);
> out = __builtin_assume_aligned (out, 16);
> for (i = 0; i < num; ++i)
> out[i] = (ovec[i] = in[i]);
> out[num] = ovec[num / 2];
> }
> -O2 -ftree-vectorize. Now, consider if this function is called
> with num != 16 (num > 16 is of course invalid, but num 0 to 15 is
> valid and your patch will cause a wrong-code in this case)
Indeed - we also "share" the epilogue loop for the cost model
check. See where we set its maximum number of iterations.
Richard.