http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57054
Bug #: 57054 Summary: Compilation with -O3 passes, with -O2 fails (ARM/NEON) Classification: Unclassified Product: gcc Version: 4.7.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: nizamov.shaw...@gmail.com While learning ARM/NEON I found what seems to be a bug in GCC/ARM. The compilation of the same function fails with: ========================== gcc -c -fPIC -fwrapv -O2 -fno-strict-aliasing -I/usr/include/python2.7 -march=armv7-a -mfpu=neon -mtune=cortex-a8 -fomit-frame-pointer -save-temps bug.c ========================== and succeeds when -O2 is changed to -O3. The error message is: ========================== In file included from bug.c:1:0: /usr/lib/gcc/arm-linux-gnueabihf/4.7/include/arm_neon.h: In function ‘streamV’: /usr/lib/gcc/arm-linux-gnueabihf/4.7/include/arm_neon.h:4994:48: error: argument must be a constant /usr/lib/gcc/arm-linux-gnueabihf/4.7/include/arm_neon.h:4994: confused by earlier errors, bailing out ========================== It seems that problem is connected with these intrinsics: vget_lane_u8(vector, lane) vgetq_lane_u16(vector, lane) when the "lane" is specified as a variable, and not as a constant. ========================== gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.7/lto-wrapper Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf Thread model: posix gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) ========================== I am using the Beagleboard XM, with a Ubuntu Raring on it (kernel is custom compiled).