This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] A new reload-rewrite pattern recognizer for GCC vectorizer.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Cong Hou <congh at google dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Biener <rguenther at suse dot de>
- Date: Sat, 26 Apr 2014 09:54:39 +0200
- Subject: Re: [PATCH] A new reload-rewrite pattern recognizer for GCC vectorizer.
- Authentication-results: sourceware.org; auth=none
- References: <CAK=A3=0Ay6rg7TPRp6DD1ROgth1F9JRHwYhnxCAhsbEWbip+nA at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Apr 24, 2014 at 05:32:54PM -0700, Cong Hou wrote:
> In this patch a new reload-rewrite pattern detector is composed to
> handle the following pattern in the loop being vectorized:
>
> x = *p;
> ...
> y = *p;
>
> or
>
> *p = x;
> ...
> y = *p;
>
> In both cases, *p is reloaded because there may exist other defs to
> another memref that may alias with p. However, aliasing is eliminated
> with alias checks. Then we can safely replace the last statement in
> above cases by y = x.
Not safely, at least not for #pragma omp simd/#pragma simd/#pragma ivdep
loops if alias analysis hasn't proven there is no aliasing.
So, IMNSHO you need to guard this with LOOP_VINFO_NO_DATA_DEPENDENCIES,
assuming it has been computed at that point already (otherwise you need to
do it elsewhere).
Consider:
void
foo (int *p, int *q)
{
int i;
#pragma omp simd safelen(16)
for (i = 0; i < 128; i++)
{
int x = *p;
*q += 8;
*p = *p + x;
p++;
q++;
}
}
It is valid to call the above with completely unrelated p and q, but
also e.g. p == q, or q == p + 16 or p == q + 16.
Your patch would certainly break it e.g. for p == q.
Jakub