[PATCH] Fix PR tree-optimization/53636 (SLP generates invalid misaligned access)

Mikael Pettersson mikpe@it.uu.se
Wed Jun 20 12:05:00 GMT 2012


Richard Guenther writes:
 > On Tue, Jun 19, 2012 at 11:36 PM, Mikael Pettersson <mikpe@it.uu.se> wrote:
 > > Richard Guenther writes:
 > >  > On Fri, Jun 15, 2012 at 5:00 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
 > >  > > Richard Guenther wrote:
 > >  > >> On Fri, Jun 15, 2012 at 3:13 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
 > >  > >> > However, there is a second case where we need to check every pass: if
 > >  > >> > we're not actually vectorizing any loop, but are performing basic-block
 > >  > >> > SLP.  In this case, it would appear that we need the same check as
 > >  > >> > described in the comment above, i.e. to verify that the stride is a
 > >  > >> > multiple of the vector size.
 > >  > >> >
 > >  > >> > The patch below adds this check, and this indeed fixes the invalid access
 > >  > >> > I was seeing in the test case (in the final assembler, we now get a
 > >  > >> > vld1.16 instead of vldr).
 > >  > >> >
 > >  > >> > Tested on arm-linux-gnueabi with no regressions.
 > >  > >> >
 > >  > >> > OK for mainline?
 > >  > >>
 > >  > >> Ok.
 > >  > >
 > >  > > Thanks for the quick review; I've checked this in to mainline now.
 > >  > >
 > >  > > I just noticed that the test case also crashes on 4.7, but not on 4.6.
 > >  > >
 > >  > > Would a backport to 4.7 also be OK, once testing passes?
 > >  >
 > >  > Yes.  Please leave it on mainline a few days to catch fallout from
 > >  > autotesters.
 > >
 > > This patch caused
 > >
 > > FAIL: gcc.dg/vect/bb-slp-16.c scan-tree-dump-times slp "basic block vectorized using SLP" 1
 > >
 > > on sparc64-linux.  Comparing the pre and post patch dumps for that file shows
 > >
 > >  22: vect_compute_data_ref_alignment:
 > >  22: misalign = 4 bytes of ref MEM[(unsigned int *)pout_90 + 28B]
 > >  22: vect_compute_data_ref_alignment:
 > > -22: force alignment of arr[i_87]
 > > -22: misalign = 0 bytes of ref arr[i_87]
 > > +22: SLP: step doesn't divide the vector-size.
 > > +22: Unknown alignment for access: arr
 > >
 > > (lots of stuff that's simply gone)
 > >
 > > -22: BASIC BLOCK VECTORIZED
 > > -
 > > -22: basic block vectorized using SLP
 > > +22: not vectorized: unsupported unaligned store.arr[i_87]
 > > +22: not vectorized: unsupported alignment in basic block.
 > 
 > In this testcase the alignment of arr[i] should be irrelevant - it is
 > not part of
 > the stmts that are going to be vectorized.  But of course this may be
 > simply an odering issue in how we analyze data-references / statements
 > in basic-block vectorization (thus we possibly did not yet declare the
 > arr[i] = i statement as not taking part in the vectorization).
 > 
 > The line
 > 
 > > -22: force alignment of arr[i_87]
 > 
 > is odd, too - as said we do not need to touch arr when vectorizing the
 > basic-block.
 > 
 > Ulrich, can you look into this or do you want me to take a look here?
 > 
 > Mikael - please open a bugreport for this.

I opened PR53729 for this, with an update saying that powerpc64-linux
also has this regression.

/Mikael



More information about the Gcc-patches mailing list