Bug 49621 - [4.5 regression] ICE in trunc_int_for_mode, at explow.c:57
Summary: [4.5 regression] ICE in trunc_int_for_mode, at explow.c:57
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.5.4
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-03 19:51 UTC by Matthias Klose
Modified: 2011-07-19 13:47 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc-linux-gnu
Build:
Known to work: 4.4.6
Known to fail: 4.5.3, 4.6.1, 4.7.0
Last reconfirmed: 2011-07-07 12:03:50


Attachments
gcc47-pr49621.patch (1.08 KB, patch)
2011-07-07 12:07 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2011-07-03 19:51:34 UTC
[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;
}
Comment 1 Jakub Jelinek 2011-07-07 12:07:10 UTC
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.
Comment 2 Jakub Jelinek 2011-07-08 20:10:16 UTC
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
Comment 3 Jakub Jelinek 2011-07-08 20:10:22 UTC
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
Comment 4 Jakub Jelinek 2011-07-08 20:18:30 UTC
Fixed for 4.6+ so far.
Comment 5 Jakub Jelinek 2011-07-19 13:09:51 UTC
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
Comment 6 Jakub Jelinek 2011-07-19 13:47:34 UTC
Fixed.