This fixes PR50698, a failure to disambiguate &MEM[&mem + 10] from &MEM[&mem] in data-reference analysis. Fixed by also looking at offsets for non-subsetted references.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2011-10-13 Richard Guenther <rguent...@suse.de> PR tree-optimization/50698 * tree-data-ref.c (split_constant_offset_1): Also process offsets of &MEM. * g++.dg/vect/pr50698.cc: New testcase. Index: gcc/tree-data-ref.c =================================================================== *** gcc/tree-data-ref.c (revision 179856) --- gcc/tree-data-ref.c (working copy) *************** split_constant_offset_1 (tree type, tree *** 589,597 **** int punsignedp, pvolatilep; op0 = TREE_OPERAND (op0, 0); - if (!handled_component_p (op0)) - return false; - base = get_inner_reference (op0, &pbitsize, &pbitpos, &poffset, &pmode, &punsignedp, &pvolatilep, false); --- 589,594 ---- Index: gcc/testsuite/g++.dg/vect/pr50698.cc =================================================================== *** gcc/testsuite/g++.dg/vect/pr50698.cc (revision 0) --- gcc/testsuite/g++.dg/vect/pr50698.cc (revision 0) *************** *** 0 **** --- 1,27 ---- + // { dg-do compile } + // { dg-require-effective-target vect_float } + + float mem[4096]; + const int N=1024; + + struct XYZ { + float * mem; + int n; + float * x() { return mem;} + float * y() { return x()+n;} + float * z() { return y()+n;} + }; + + inline + void sum(float * x, float * y, float * z, int n) { + for (int i=0;i!=n; ++i) + x[i]=y[i]+z[i]; + } + + void sumS() { + XYZ xyz; xyz.mem=mem; xyz.n=N; + sum(xyz.x(),xyz.y(),xyz.z(),xyz.n); + } + + // { dg-final { scan-tree-dump-not "run-time aliasing" "vect" } } + // { dg-final { cleanup-tree-dump "vect" } }