------- Comment #7 from pinskia at gmail dot com 2008-03-23 16:50 ------- Subject: Re: [4.3/4.4 Regression]: gcc-4.3 -O3/-ftree-vectorize regression: incorrect code generation
This code violates c/c++ aliasing rules. Sent from my iPhone On Mar 23, 2008, at 6:33, "victork at gcc dot gnu dot org" <[EMAIL PROTECTED] > wrote: > > > ------- Comment #6 from victork at gcc dot gnu dot org 2008-03-23 > 13:33 ------- > Here is AN even more reduced example which demonstrates the problem: > int main() > { > char buf[256]; > char *dest; > int i; > > dest = &buf[2]; > for (i = 0; i < 32; i++) > { > *(unsigned *)dest = 0; > dest += 4; > } > > return buf[2]; > } > > gcc -O3 t.c && ./a.out > Segmentation fault > > > The problem is that vectorizer is assuming that the access was > aligned to the > the size of the element before vectorization. A loop peeling only > handles > misalignment in multiples of element size. > In this case, vectorizer could check the actual alignment in compile > time and > prevent vectorization. (Though the assignment of a constant still > can be > vectorized if value of constant is adjusted accordingly). > In general case, when alignment of the non-vectorized access is > unknown, a fix > of this bug would require an addition of a run-time test. > > > -- > > victork at gcc dot gnu dot org changed: > > What |Removed |Added > --- > --- > ---------------------------------------------------------------------- > AssignedTo|unassigned at gcc dot gnu |victork at gcc dot > gnu dot > |dot org |org > Status|NEW |ASSIGNED > Last reconfirmed|2008-03-21 17:47:58 |2008-03-23 13:33:08 > date| | > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35653 > -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35653