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