http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52457
Bug #: 52457 Summary: Wrong VSX code generation bug when compiled with -O1 -m32 -mcpu=power7 Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: berg...@gcc.gnu.org ReportedBy: berg...@gcc.gnu.org CC: meiss...@gcc.gnu.org Host: powerpc*-linux Target: powerpc*-linux Build: powerpc*-linux The following test case aborts when compiled with -O1 and -O2, but runs successfully when compiled with -O0 and -O3. The wrong code generation occurs in the function buggy_func(). The bug is caused by a typo in the rs600/vsx.md's vsx_set_<mode> pattern. bergner@igoo:~> cat bug.c extern void abort (void); typedef long long T; typedef T vl_t __attribute__((vector_size(2 * sizeof (T)))); vl_t buggy_func (T x) { vl_t w; T *p = (T *)&w; p[0] = p[1] = x; return w; } int main(void) { vl_t rval; T *pl; pl = (T *) &rval; rval = buggy_func (2); if (pl[0] != 2 || pl[1] != 2) abort (); return 0; } bergner@igoo:~> /home/bergner/gcc/build/gcc-mainline-testsuite/gcc/xgcc -B/home/bergner/gcc/build/gcc-mainline-testsuite/gcc/ -O0 -m32 -mcpu=power7 bug.c bergner@igoo:~> ./a.out bergner@igoo:~> /home/bergner/gcc/build/gcc-mainline-testsuite/gcc/xgcc -B/home/bergner/gcc/build/gcc-mainline-testsuite/gcc/ -O1 -m32 -mcpu=power7 bug.c bergner@igoo:~> ./a.out Aborted