public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data
@ 2012-07-15  8:40 hayim at post dot tau.ac.il
  2012-07-15 13:54 ` [Bug c++/53970] " hjl.tools at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: hayim at post dot tau.ac.il @ 2012-07-15  8:40 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53970
           Summary: -ftree-vectorization does not handle well unaligned
                    data
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hayim@post.tau.ac.il


When compiling this code:

#pragma pack(1)
struct mystruct {
    char c;
    unsigned long l[1024];
};
#pragma pack()

int main(int argc, char **argv) {
    mystruct *a = new mystruct;

    unsigned long long i;

    for (i = 0; i < 1024; ++i)
        a->l[i] = 0xdeadbeaf;
}


with -O2 -ftree-vectorize -Wall, the code crashes.
More specifically, the loop is vectorized assuming alignment (movdqa), which
causes the crash.

I think the proper behaviour should be to print a warning message at compile
time that an unaligned data is used, or even vectorize the loop without
assuming alignment.


(co-finders: Tomer Cohen and Ofek Ben-Arie)


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

* [Bug c++/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
@ 2012-07-15 13:54 ` hjl.tools at gmail dot com
  2012-07-15 16:48 ` hp at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2012-07-15 13:54 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
          Component|c                           |c++
         Resolution|                            |DUPLICATE

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2012-07-15 13:54:21 UTC ---
Dup.

*** This bug has been marked as a duplicate of bug 36159 ***


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

* [Bug c++/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
  2012-07-15 13:54 ` [Bug c++/53970] " hjl.tools at gmail dot com
@ 2012-07-15 16:48 ` hp at gcc dot gnu.org
  2012-07-16  9:40 ` [Bug tree-optimization/53970] " rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hp at gcc dot gnu.org @ 2012-07-15 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
                 CC|                            |hp at gcc dot gnu.org
         Resolution|DUPLICATE                   |

--- Comment #2 from Hans-Peter Nilsson <hp at gcc dot gnu.org> 2012-07-15 16:48:16 UTC ---
(In reply to comment #1)
> Dup.

No...?  I think you missed the explicit "char" member in the struct being
new:ed, making the data *known* misaligned.  Or was it I who missed something?
(Changing back to unconfirmed as I didn't confirm the bahavior.)


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

* [Bug tree-optimization/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
  2012-07-15 13:54 ` [Bug c++/53970] " hjl.tools at gmail dot com
  2012-07-15 16:48 ` hp at gcc dot gnu.org
@ 2012-07-16  9:40 ` rguenth at gcc dot gnu.org
  2012-07-16 14:53 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-16  9:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2012-07-16
          Component|c++                         |tree-optimization
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1
      Known to fail|                            |4.6.3, 4.7.1, 4.8.0

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-16 09:40:20 UTC ---
Confirmed, mine.


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

* [Bug tree-optimization/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
                   ` (2 preceding siblings ...)
  2012-07-16  9:40 ` [Bug tree-optimization/53970] " rguenth at gcc dot gnu.org
@ 2012-07-16 14:53 ` rguenth at gcc dot gnu.org
  2012-07-18  8:33 ` ebotcazou at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-16 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-16 14:53:21 UTC ---
The only hint we have on the a->l[i] expression that it involves a packed
aggregate is DECL_ALIGN of the 'l' FIELD_DECL and TYPE_ALIGN of mystruct
itself.  Nowhere we have a TYPE/DECL_PACKED flag set.  That is because how
pragma pack works - it simply adjusts the global maximum_field_alignment
of stor-layout.c.

That means that expr.c:contains_packed_reference does not work.


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

* [Bug tree-optimization/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
                   ` (3 preceding siblings ...)
  2012-07-16 14:53 ` rguenth at gcc dot gnu.org
@ 2012-07-18  8:33 ` ebotcazou at gcc dot gnu.org
  2012-07-18 10:46 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-07-18  8:33 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org

--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-07-18 08:32:53 UTC ---
> That means that expr.c:contains_packed_reference does not work.

Absolutely, contains_packed_reference is wrong since DECL_PACKED is only meant
to drive stor-layout.c (and dwarf2out.c), i.e. it's only a declarative flag.


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

* [Bug tree-optimization/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
                   ` (4 preceding siblings ...)
  2012-07-18  8:33 ` ebotcazou at gcc dot gnu.org
@ 2012-07-18 10:46 ` rguenth at gcc dot gnu.org
  2012-07-18 10:46 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-18 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-18 10:46:11 UTC ---
Author: rguenth
Date: Wed Jul 18 10:46:05 2012
New Revision: 189609

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189609
Log:
2012-07-18  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/53970
    * tree.h (contains_packed_reference): Remove.
    * expr.c (contains_packed_reference): Likewise.
    * tree-vect-data-refs.c (not_size_aligned): New function.
    (vector_alignment_reachable_p): Use it.
    (vect_supportable_dr_alignment): Likewise.

    * g++.dg/torture/pr53970.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr53970.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-data-refs.c
    trunk/gcc/tree.h

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-18 10:46:34 UTC ---
Fixed for GCC 4.8.


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

* [Bug tree-optimization/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
                   ` (5 preceding siblings ...)
  2012-07-18 10:46 ` rguenth at gcc dot gnu.org
@ 2012-07-18 10:46 ` rguenth at gcc dot gnu.org
  2012-07-18 10:47 ` rguenth at gcc dot gnu.org
  2012-07-19  8:48 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-18 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-18 10:46:11 UTC ---
Author: rguenth
Date: Wed Jul 18 10:46:05 2012
New Revision: 189609

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189609
Log:
2012-07-18  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/53970
    * tree.h (contains_packed_reference): Remove.
    * expr.c (contains_packed_reference): Likewise.
    * tree-vect-data-refs.c (not_size_aligned): New function.
    (vector_alignment_reachable_p): Use it.
    (vect_supportable_dr_alignment): Likewise.

    * g++.dg/torture/pr53970.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr53970.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-data-refs.c
    trunk/gcc/tree.h


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

* [Bug tree-optimization/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
                   ` (6 preceding siblings ...)
  2012-07-18 10:46 ` rguenth at gcc dot gnu.org
@ 2012-07-18 10:47 ` rguenth at gcc dot gnu.org
  2012-07-19  8:48 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-18 10:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-18 10:46:34 UTC ---
Fixed for GCC 4.8.


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

* [Bug tree-optimization/53970] -ftree-vectorization does not handle well unaligned data
  2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
                   ` (7 preceding siblings ...)
  2012-07-18 10:47 ` rguenth at gcc dot gnu.org
@ 2012-07-19  8:48 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-19  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-19 08:48:05 UTC ---
Author: rguenth
Date: Thu Jul 19 08:48:01 2012
New Revision: 189647

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189647
Log:
2012-07-19  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/53970
    * tree-vect-data-refs.c (not_size_aligned): Avoid sign-compare
    warning.

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


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

end of thread, other threads:[~2012-07-19  8:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-15  8:40 [Bug c/53970] New: -ftree-vectorization does not handle well unaligned data hayim at post dot tau.ac.il
2012-07-15 13:54 ` [Bug c++/53970] " hjl.tools at gmail dot com
2012-07-15 16:48 ` hp at gcc dot gnu.org
2012-07-16  9:40 ` [Bug tree-optimization/53970] " rguenth at gcc dot gnu.org
2012-07-16 14:53 ` rguenth at gcc dot gnu.org
2012-07-18  8:33 ` ebotcazou at gcc dot gnu.org
2012-07-18 10:46 ` rguenth at gcc dot gnu.org
2012-07-18 10:46 ` rguenth at gcc dot gnu.org
2012-07-18 10:47 ` rguenth at gcc dot gnu.org
2012-07-19  8:48 ` 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).