public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses
@ 2012-06-11 17:22 uweigand at gcc dot gnu.org
  2012-06-11 17:24 ` [Bug tree-optimization/53636] " uweigand at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: uweigand at gcc dot gnu.org @ 2012-06-11 17:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

             Bug #: 53636
           Summary: SLP may create invalid unaligned memory accesses
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: uweigand@gcc.gnu.org


The following test case:

void test (unsigned char *dst)
{
 short tmp[11 * 8], *tptr;
 int i;

 fill (tmp);

 tptr = tmp;
 for (i = 0; i < 8; i++)
   {
     dst[0] = (-tptr[0] + 9 * tptr[0 + 1] + 9 * tptr[0 + 2] - tptr[0 + 3]) >>
7;
     dst[1] = (-tptr[1] + 9 * tptr[1 + 1] + 9 * tptr[1 + 2] - tptr[1 + 3]) >>
7;
     dst[2] = (-tptr[2] + 9 * tptr[2 + 1] + 9 * tptr[2 + 2] - tptr[2 + 3]) >>
7;
     dst[3] = (-tptr[3] + 9 * tptr[3 + 1] + 9 * tptr[3 + 2] - tptr[3 + 3]) >>
7;
     dst[4] = (-tptr[4] + 9 * tptr[4 + 1] + 9 * tptr[4 + 2] - tptr[4 + 3]) >>
7;
     dst[5] = (-tptr[5] + 9 * tptr[5 + 1] + 9 * tptr[5 + 2] - tptr[5 + 3]) >>
7;
     dst[6] = (-tptr[6] + 9 * tptr[6 + 1] + 9 * tptr[6 + 2] - tptr[6 + 3]) >>
7;
     dst[7] = (-tptr[7] + 9 * tptr[7 + 1] + 9 * tptr[7 + 2] - tptr[7 + 3]) >>
7;

     dst += 8;
     tptr += 11;
   }
}

when built on ARM with -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp -O
-ftree-vectorize creates code that uses a VLDR instruction to access unaligned
memory, which causes a Bus error at runtime.

The problem seems to be that the check in vect_compute_data_ref_alignment is
not enough for SLP.  Even though SLP only considers a basic blokc, the data-ref
analysis still looks at innermost loops to compute scalar evolutions.  This
results in concluding that the access "tptr[0]" is based on "tmp", which is
aligned to 8 bytes, using a step of 22 bytes.

The alignment check now only verified that the *base* is aligned.  This is OK
if we're actually vectorizing the loop.  But in the SLP case, we really need to
verify instead that the access is aligned on *every* iteration through the loop
...


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
@ 2012-06-11 17:24 ` uweigand at gcc dot gnu.org
  2012-06-15 13:30 ` uweigand at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: uweigand at gcc dot gnu.org @ 2012-06-11 17:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

Ulrich Weigand <uweigand at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-06-11
         AssignedTo|unassigned at gcc dot       |uweigand at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
  2012-06-11 17:24 ` [Bug tree-optimization/53636] " uweigand at gcc dot gnu.org
@ 2012-06-15 13:30 ` uweigand at gcc dot gnu.org
  2012-06-15 15:12 ` uweigand at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: uweigand at gcc dot gnu.org @ 2012-06-15 13:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

--- Comment #1 from Ulrich Weigand <uweigand at gcc dot gnu.org> 2012-06-15 13:30:40 UTC ---
Author: uweigand
Date: Fri Jun 15 13:30:36 2012
New Revision: 188661

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188661
Log:
    gcc/
    PR tree-optimization/53636
    * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Verify
    stride when doing basic-block vectorization.

    gcc/testsuite/
    PR tree-optimization/53636
    * gcc.target/arm/pr53636.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/arm/pr53636.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-data-refs.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
  2012-06-11 17:24 ` [Bug tree-optimization/53636] " uweigand at gcc dot gnu.org
  2012-06-15 13:30 ` uweigand at gcc dot gnu.org
@ 2012-06-15 15:12 ` uweigand at gcc dot gnu.org
  2012-06-26  9:06 ` uweigand at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: uweigand at gcc dot gnu.org @ 2012-06-15 15:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

--- Comment #2 from Ulrich Weigand <uweigand at gcc dot gnu.org> 2012-06-15 15:11:51 UTC ---
Now fixed on mainline; still fails on 4.7.

(While the bug is probably latent even earlier, this particular test case does
not crash on 4.6.)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-06-15 15:12 ` uweigand at gcc dot gnu.org
@ 2012-06-26  9:06 ` uweigand at gcc dot gnu.org
  2012-09-29 23:56 ` [Bug tree-optimization/53636] [4.7 Regression] " pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: uweigand at gcc dot gnu.org @ 2012-06-26  9:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

--- Comment #3 from Ulrich Weigand <uweigand at gcc dot gnu.org> 2012-06-26 09:05:56 UTC ---
Author: uweigand
Date: Tue Jun 26 09:05:48 2012
New Revision: 188979

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188979
Log:
    PR tree-optimization/53729
    PR tree-optimization/53636
    * tree-vect-slp.c (vect_slp_analyze_bb_1): Delay call to
    vect_verify_datarefs_alignment until after statements have
    been marked as relevant/irrelevant.
    * tree-vect-data-refs.c (vect_verify_datarefs_alignment):
    Skip irrelevant statements.
    (vect_enhance_data_refs_alignment): Use STMT_VINFO_RELEVANT_P
    instead of STMT_VINFO_RELEVANT.
    (vect_get_data_access_cost): Do not check for supportable
    alignment before calling vect_get_load_cost/vect_get_store_cost.
    * tree-vect-stmts.c (vect_get_store_cost): Do not abort when
    handling unsupported alignment.
    (vect_get_load_cost): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vect-data-refs.c
    trunk/gcc/tree-vect-slp.c
    trunk/gcc/tree-vect-stmts.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] [4.7 Regression] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-06-26  9:06 ` uweigand at gcc dot gnu.org
@ 2012-09-29 23:56 ` pinskia at gcc dot gnu.org
  2012-12-03 15:33 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-09-29 23:56 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.7.3
            Summary|SLP may create invalid      |[4.7 Regression] SLP may
                   |unaligned memory accesses   |create invalid unaligned
                   |                            |memory accesses


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] [4.7 Regression] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-09-29 23:56 ` [Bug tree-optimization/53636] [4.7 Regression] " pinskia at gcc dot gnu.org
@ 2012-12-03 15:33 ` rguenth at gcc dot gnu.org
  2013-04-11  8:00 ` rguenth at gcc dot gnu.org
  2014-06-12 13:12 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 15:33 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
           Priority|P3                          |P2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] [4.7 Regression] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2012-12-03 15:33 ` rguenth at gcc dot gnu.org
@ 2013-04-11  8:00 ` rguenth at gcc dot gnu.org
  2014-06-12 13:12 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-11  8:00 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.3                       |4.7.4

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-11 07:59:39 UTC ---
GCC 4.7.3 is being released, adjusting target milestone.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/53636] [4.7 Regression] SLP may create invalid unaligned memory accesses
  2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-04-11  8:00 ` rguenth at gcc dot gnu.org
@ 2014-06-12 13:12 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53636

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |4.8.0
         Resolution|---                         |FIXED
   Target Milestone|4.7.4                       |4.8.0
      Known to fail|                            |4.7.4

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for 4.8.0(?)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-06-12 13:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-11 17:22 [Bug tree-optimization/53636] New: SLP may create invalid unaligned memory accesses uweigand at gcc dot gnu.org
2012-06-11 17:24 ` [Bug tree-optimization/53636] " uweigand at gcc dot gnu.org
2012-06-15 13:30 ` uweigand at gcc dot gnu.org
2012-06-15 15:12 ` uweigand at gcc dot gnu.org
2012-06-26  9:06 ` uweigand at gcc dot gnu.org
2012-09-29 23:56 ` [Bug tree-optimization/53636] [4.7 Regression] " pinskia at gcc dot gnu.org
2012-12-03 15:33 ` rguenth at gcc dot gnu.org
2013-04-11  8:00 ` rguenth at gcc dot gnu.org
2014-06-12 13:12 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).