]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: Enforce dr_with_seg_len::align precondition [PR116125]
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 25 Apr 2025 11:04:46 +0000 (12:04 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Fri, 25 Apr 2025 11:04:46 +0000 (12:04 +0100)
commita895b98c6722277c5129dd5d813bbb2e8ac9c98f
treeca837cc6f5278ced72ec56143d05f1908c9fbdeb
parent8eabfcb8b09a54bbf3252811c3ba378e2fc3e44a
vect: Enforce dr_with_seg_len::align precondition [PR116125]

tree-data-refs.cc uses alignment information to try to optimise
the code generated for alias checks.  The assumption for "normal"
non-grouped, full-width scalar accesses was that the access size
would be a multiple of the alignment.  As Richi notes in the PR,
this is a documented precondition of dr_with_seg_len:

  /* The minimum common alignment of DR's start address, SEG_LEN and
     ACCESS_SIZE.  */
  unsigned int align;

PR115192 was a case in which this assumption didn't hold.  The access
was part of an aligned 4-element group, but only the first 2 elements
of the group were accessed.  The alignment was therefore double the
access size.

In r15-820-ga0fe4fb1c8d78045 I'd "fixed" that by capping the
alignment in one of the output routines.  But I think that was
misconceived.  The precondition means that we should cap the
alignment at source instead.

Failure to do that caused a similar wrong code bug in this PR,
where the alignment comes from a short bitfield access rather
than from a group access.

gcc/
PR tree-optimization/116125
* tree-vect-data-refs.cc (vect_prune_runtime_alias_test_list): Make
the dr_with_seg_len alignment fields describe tha access sizes as
well as the pointer alignment.
* tree-data-ref.cc (create_intersect_range_checks): Don't compensate
for invalid alignment fields here.

gcc/testsuite/
PR tree-optimization/116125
* gcc.dg/vect/pr116125.c: New test.

(cherry picked from commit e8651b80aeb86da935035e218747a6b41b611497)
gcc/testsuite/gcc.dg/vect/pr116125.c [new file with mode: 0644]
gcc/tree-data-ref.cc
gcc/tree-vect-data-refs.cc