http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60276
Bug ID: 60276 Summary: -O3 autovectorizer breaks on a particular loop Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: maister at archlinux dot us Created attachment 32174 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32174&action=edit Reduced testcase GCC 4.8.2 with -O3 breaks a certain loop I'm compiling. Disabling the vectorizer with -fno-tree-vectorize fixes the issue, as well as compiling with -O2. I've reduced the problem to a small test case which is attached as legall.c. Distro: Arch Linux x86_64 gcc -v: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc/src/gcc-4.8-20140206/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --disable-cloog-version-check --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 4.8.2 20140206 (prerelease) (GCC) Miscompile: gcc -o legall legall.c -std=gnu99 -O3 Working: gcc -o legall legall.c -std=gnu99 -O3 -fno-tree-vectorize Expected output: (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) (25) (26) (27) (28) (29) (30) (31) (32) (33) (34) (35) (36) (37) (38) (39) (40) (41) (42) (43) (44) (45) (46) (47) (48) Wrong output by -O3: (0) (1) (2) (2) (4) (3) (6) (4) (8) (5) (10) (6) (12) (7) (14) (8) (16) (17) (18) (10) (20) (11) (22) (12) (24) (13) (26) (14) (28) (15) (30) (16) (32) (33) (34) (35) (36) (37) (38) (39) (40) (41) (42) (43) (44) (45) (46) (47) (48)