In the following short program (preprocessed files will be attached), the output is incorrect when compiled with
ppu-g++ -o bug -O3 bug.cpp -maltivec I get the output: 0.000000 1.000000 2.000000 3.000000 0.000000 0.000000 0.000000 7.000000 0.000000 0.000000 0.000000 30.000000 0.000000 0.000000 0.000000 15.000000 I was expecting: 0.000000 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000 10.000000 11.000000 12.000000 13.000000 14.000000 15.000000 --- cut here --- #include <altivec.h> #include <cstdio> struct mat { vector float v0; vector float v1; vector float v2; vector float v3; }; vector float load_vec_unaligned(const float* a) { return vec_or(vec_lvlx(0, a), vec_lvrx(16, a)); } mat load_unaligned(const float* a) { mat m; m.v0 = load_vec_unaligned(a); m.v1 = load_vec_unaligned(a+4); m.v2 = load_vec_unaligned(a+8); m.v3 = load_vec_unaligned(a+12); return m; } int main() { __attribute__((aligned(16))) float f[18] = {-12.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, -12.0f}; const mat m = load_unaligned(&f[1]); union { vector float v; float f[4]; } u; u.v = m.v0; printf("%f %f %f %f\n", u.f[0], u.f[1], u.f[2], u.f[3]); u.v = m.v1; printf("%f %f %f %f\n", u.f[0], u.f[1], u.f[2], u.f[3]); u.v = m.v2; printf("%f %f %f %f\n", u.f[0], u.f[1], u.f[2], u.f[3]); u.v = m.v3; printf("%f %f %f %f\n", u.f[0], u.f[1], u.f[2], u.f[3]); } --- cut here --- For some reason, the load_unaligned function compiles correctly but something goes wrong during inlining, as the vor instructions are not correct. If I mark load_unaligned with __attribute__((noinline)), or compile with -O2, I get the expected output. -- Summary: gcc does not produce necessary vec_lvrx instructions Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ryan dot sammartino at gmail dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: ppu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42920