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: unassig...@gcc.gnu.org
        ReportedBy: ha...@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)

Reply via email to