http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54446
Bug #: 54446 Summary: Stack needlessly aligned with AVX Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: ces...@cesarb.net When compiling the following small function, gcc aligns the stack, even though the function does not store any AVX values in the stack: bool test(__m256i *p) { __m256i x = _mm256_load_si256(p); return _mm256_testz_si256(x, x); } The generated assembly output is: test: pushq %rbp movq %rsp, %rbp andq $-32, %rsp addq $16, %rsp vmovdqa (%rdi), %ymm0 vptest %ymm0, %ymm0 leave sete %al vzeroupper ret The assembly output should instead be something like: test: vmovdqa (%rdi), %ymm0 vptest %ymm0, %ymm0 sete %al vzeroupper ret The command line is "gcc -mavx -std=c99 -O3 -Wall -Wextra -Werror -save-temps". Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.6.3/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.6.3 20120306 (Red Hat 4.6.3-2) (GCC)