http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61068
Bug ID: 61068
Summary: -O3 generates bad code (when tree-vectorize or
inline-functions is on)
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: wence at gmx dot li
Created attachment 32738
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32738&action=edit
preprocessed source
The attached program segfaults at runtime when compiled with -O3. If I compile
with either -fno-tree-vectorize or -fno-inline then the output is correct
(verified externally, this is a cut down example).
Note that if I split the increments into A[j][k] and A[(j+3)][(k+3)] into
separate loops, then the segfault also goes away.
I am currently building 4.9 to see if the problem still exists there.
Compilation command:
gcc-4.8 -v -std=c99 -O3 foo.c -save-temps
-v output:
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/lto-wrapper
Target: x86_64-apple-darwin13.0.0
Configured with: ../configure --build=x86_64-apple-darwin13.0.0
--prefix=/usr/local/Cellar/gcc48/4.8.2 --enable-languages=c,c++,objc,obj-c++
--program-suffix=-4.8 --with-gmp=/usr/local/opt/gmp4
--with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08
--with-cloog=/usr/local/opt/cloog018 --with-isl=/usr/local/opt/isl011
--with-system-zlib --enable-version-specific-runtime-libs
--enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release
--enable-lto --disable-werror --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 4.8.2 (GCC)
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.1' '-v' '-std=c99' '-O3'
'-save-temps' '-mtune=core2'
/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/cc1
-E -quiet -v -D__DYNAMIC__ foo.c -fPIC -mmacosx-version-min=10.9.1 -mtune=core2
-std=c99 -O3 -fpch-preprocess -o foo.i
ignoring nonexistent directory "/usr/local/Cellar/gcc48/4.8.2/include"
ignoring nonexistent directory
"/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/../../../../x86_64-apple-darwin13.0.0/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include
/usr/local/include
/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include-fixed
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.1' '-v' '-std=c99' '-O3'
'-save-temps' '-mtune=core2'
/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/cc1
-fpreprocessed foo.i -fPIC -quiet -dumpbase foo.c -mmacosx-version-min=10.9.1
-mtune=core2 -auxbase foo -O3 -std=c99 -version -o foo.s
GNU C (GCC) version 4.8.2 (x86_64-apple-darwin13.0.0)
compiled by GNU C version 4.8.2, GMP version 4.3.2, MPFR version 2.4.2, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.8.2 (x86_64-apple-darwin13.0.0)
compiled by GNU C version 4.8.2, GMP version 4.3.2, MPFR version 2.4.2, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 077b529d6cfe035508c45a2f30143407
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.1' '-v' '-std=c99' '-O3'
'-save-temps' '-mtune=core2'
as -arch x86_64 -force_cpusubtype_ALL -o foo.o foo.s
COMPILER_PATH=/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/:/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/:/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/:/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/:/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/
LIBRARY_PATH=/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/:/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.1' '-v' '-std=c99' '-O3'
'-save-temps' '-mtune=core2'
/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/collect2
-dynamic -arch x86_64 -macosx_version_min 10.9.1 -weak_reference_mismatches
non-weak -o a.out
-L/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2
-L/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/../../..
foo.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 4.8.2
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.9.1
-weak_reference_mismatches non-weak -o a.out
-L/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2
-L/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/../../..
foo.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld PROJECT:ld64-236.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m
armv7em
Library search paths:
/usr/local/Cellar/gcc48/4.8.2/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2
/usr/local/Cellar/gcc48/4.8.2/lib
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/