[forwarded from http://bugs.debian.org/632510] works with 4.4.6, fails with recent 4.5 and 4.6 branches and trunk (powerpc-linux) $ gcc -c -O -maltivec -g foo.i foo.i: In function 'foo': foo.i:17:1: internal compiler error: in trunc_int_for_mode, at explow.c:56 Please submit a full bug report, with preprocessed source if appropriate. int foo(void) { __attribute__((altivec(vector__))) unsigned a, b, c; unsigned k = 1; a = (__attribute__((altivec(vector__))) unsigned) { 0, 0, 0, 1 }; b = c = (__attribute__((altivec(vector__))) unsigned) { 0, 0, 0, 0 }; a = __builtin_vec_add(a, __builtin_vec_splats(k)); b = __builtin_vec_add(b, a); c = __builtin_vec_sel(c, a, b); if (__builtin_vec_vcmpeq_p(1, b, c)) return 1; return 0; }
Created attachment 24706 [details] gcc47-pr49621.patch I believe the bug is in the ppc vector select patterns, comparing a vector mode reg with const0_rtx in a NE is bound to confuse the middle-end. Both operands of a comparison should always have either the same mode, or one should be VOIDmode and the other should have integer or CC mode. The following patch fixes this, completely untested so far.
Author: jakub Date: Fri Jul 8 20:09:58 2011 New Revision: 176063 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176063 Log: PR target/49621 * config/rs6000/rs6000.c (rs6000_emit_vector_cond_expr): Use CONST0_RTX (dest_mode) instead of const0_rtx as second operand of NE. * config/rs6000/vector.md (vector_select_<mode>, vector_select_<mode>_uns): Change second operand of NE to CONST0_RTX (<MODE>mode) instead of const0_rtx. * config/rs6000/altivec.md (*altivec_vsel<mode>, *altivec_vsel<mode>_uns): Expect second operand of NE to be zero_constant of the corresponding vector mode. * config/rs6000/vsx.md (*vsx_xxsel<mode>, *vsx_xxsel<mode>_uns): Likewise. * gcc.target/powerpc/altivec-34.c: New test. Added: trunk/gcc/testsuite/gcc.target/powerpc/altivec-34.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/rs6000/altivec.md trunk/gcc/config/rs6000/rs6000.c trunk/gcc/config/rs6000/vector.md trunk/gcc/config/rs6000/vsx.md trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Fri Jul 8 20:10:18 2011 New Revision: 176064 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176064 Log: PR target/49621 * config/rs6000/rs6000.c (rs6000_emit_vector_cond_expr): Use CONST0_RTX (dest_mode) instead of const0_rtx as second operand of NE. * config/rs6000/vector.md (vector_select_<mode>, vector_select_<mode>_uns): Change second operand of NE to CONST0_RTX (<MODE>mode) instead of const0_rtx. * config/rs6000/altivec.md (*altivec_vsel<mode>, *altivec_vsel<mode>_uns): Expect second operand of NE to be zero_constant of the corresponding vector mode. * config/rs6000/vsx.md (*vsx_xxsel<mode>, *vsx_xxsel<mode>_uns): Likewise. * gcc.target/powerpc/altivec-34.c: New test. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.target/powerpc/altivec-34.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/config/rs6000/altivec.md branches/gcc-4_6-branch/gcc/config/rs6000/rs6000.c branches/gcc-4_6-branch/gcc/config/rs6000/vector.md branches/gcc-4_6-branch/gcc/config/rs6000/vsx.md branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Fixed for 4.6+ so far.
Author: jakub Date: Tue Jul 19 13:09:48 2011 New Revision: 176458 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176458 Log: Backport from mainline 2011-07-08 Jakub Jelinek <jakub@redhat.com> PR target/49621 * config/rs6000/rs6000.c (rs6000_emit_vector_cond_expr): Use CONST0_RTX (dest_mode) instead of const0_rtx as second operand of NE. * config/rs6000/vector.md (vector_select_<mode>, vector_select_<mode>_uns): Change second operand of NE to CONST0_RTX (<MODE>mode) instead of const0_rtx. * config/rs6000/altivec.md (*altivec_vsel<mode>, *altivec_vsel<mode>_uns): Expect second operand of NE to be zero_constant of the corresponding vector mode. * config/rs6000/vsx.md (*vsx_xxsel<mode>, *vsx_xxsel<mode>_uns): Likewise. * gcc.target/powerpc/altivec-34.c: New test. Added: branches/gcc-4_5-branch/gcc/testsuite/gcc.target/powerpc/altivec-34.c Modified: branches/gcc-4_5-branch/gcc/ChangeLog branches/gcc-4_5-branch/gcc/config/rs6000/altivec.md branches/gcc-4_5-branch/gcc/config/rs6000/rs6000.c branches/gcc-4_5-branch/gcc/config/rs6000/vector.md branches/gcc-4_5-branch/gcc/config/rs6000/vsx.md branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Fixed.