http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47755
Summary: VSX code generates a TOC reference to clear memory Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: target AssignedTo: meiss...@gcc.gnu.org ReportedBy: meiss...@gcc.gnu.org Host: powerpc64-linux Target: powerpc64-linux Build: powerpc64-linux If you have an array of pointers or longs in 64-bit mode that you want to clear, via loops like when you have automatic vectorization on: for (i = 0; i < sizeof (array) / sizeof (array[0]); i++) array[i] = 0; The compiler generates the 128-bit zero constant, puts it into the constant pool, and loads it from memory in order to set the array with vector instructions. Normally this would be a missed optimization, but we discovered it in compiling _dl_start with -O3 -mcpu=power7, and at the time _dl_start is run, the TOC registers are not yet set up, so the program crashes before it starts. The cause of the bug is that V2DI mode is not true for either VSX_VECTOR_MODE or ALTIVEC_VECTOR_MODE, since there are no native 64-bit operations in the VSX or Altivec vector instructions. This means that easy_vector_constant fails, which in turn makes LEGITIMATE_CONSTANT_P fail. The solution is use macros that test whether Altivec/VSX memory references can be done, instead of macros that say we have native arithmetic support for those modes.