https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77895
Bug ID: 77895
Summary: Unaligned movdqa generated by GCC 6.2.0 with -O3
Product: gcc
Version: 6.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jack.d.whitham at gmail dot com
Target Milestone: ---
Created attachment 39766
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39766&action=edit
Test case to reproduce bug
A strange custom implementation of "memcpy" from a data compression library is
badly vectorized by GCC 6.2.0 when using "-O3", or alternatively "-O1
-fvect-cost-model -ftree-loop-vectorize". The vectorizer seems to assume that
the "src" address is word-aligned, but there is no reason to assume so (it's an
"unsigned char*"). The program segfaults at the "movdqa" instruction.
Bug can be reproduced with GCC 6.2.0 on Debian "sid" AMD64:
$ gcc-6 -v
Using built-in specs.
COLLECT_GCC=gcc-6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.2.0-5'
--with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 6.2.0 20160927 (Debian 6.2.0-5)
$ gcc-6 -O3 example.c -o example
$ ./example
Segmentation fault
This bug is also in GCC 5.4.1 and GCC 4.9.4, but apparently not in GCC 4.8.
This bug occurs with x86 code as well as AMD64.
Please accept my apologies for guessing about the component and if this issue
is already known. I searched for duplicates and found a number of
similar-sounding bugs, but all were marked as "resolved" in earlier versions of
GCC.