]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: Fix access size alignment assumption [PR115192]
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 24 May 2024 12:47:21 +0000 (13:47 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Fri, 24 May 2024 12:47:21 +0000 (13:47 +0100)
commita0fe4fb1c8d7804515845dd5d2a814b3c7a1ccba
tree6ee17e44b90f1a19ac2215303c40dc0d856cf183
parent5833e5b8ef40367764325f4f3c80cfa129fbe1da
vect: Fix access size alignment assumption [PR115192]

create_intersect_range_checks checks whether two access ranges
a and b are alias-free using something equivalent to:

  end_a <= start_b || end_b <= start_a

It has two ways of doing this: a "vanilla" way that calculates
the exact exclusive end pointers, and another way that uses the
last inclusive aligned pointers (and changes the comparisons
accordingly).  The comment for the latter is:

      /* Calculate the minimum alignment shared by all four pointers,
 then arrange for this alignment to be subtracted from the
 exclusive maximum values to get inclusive maximum values.
 This "- min_align" is cumulative with a "+ access_size"
 in the calculation of the maximum values.  In the best
 (and common) case, the two cancel each other out, leaving
 us with an inclusive bound based only on seg_len.  In the
 worst case we're simply adding a smaller number than before.

The problem is that the associated code implicitly assumed that the
access size was a multiple of the pointer alignment, and so the
alignment could be carried over to the exclusive end pointer.

The testcase started failing after g:9fa5b473b5b8e289b6542
because that commit improved the alignment information for
the accesses.

gcc/
PR tree-optimization/115192
* tree-data-ref.cc (create_intersect_range_checks): Take the
alignment of the access sizes into account.

gcc/testsuite/
PR tree-optimization/115192
* gcc.dg/vect/pr115192.c: New test.
gcc/testsuite/gcc.dg/vect/pr115192.c [new file with mode: 0644]
gcc/tree-data-ref.cc