re PR middle-end/29584 (internal compiler error on optimization)

PR middle-end/29584
	* tree-ssa-forwprop.c (simplify_switch_expr): Don't
	optimize if DEF doesn't have integral type.

	* gcc.dg/torture/pr29584.c: New test.

From-SVN: r118921
This commit is contained in:
Jakub Jelinek 2006-11-17 09:57:45 +01:00 committed by Jakub Jelinek
parent 3e0a5abd21
commit c7b38a8574
4 changed files with 42 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2006-11-17 Jakub Jelinek <jakub@redhat.com>
PR middle-end/29584
* tree-ssa-forwprop.c (simplify_switch_expr): Don't
optimize if DEF doesn't have integral type.
2006-11-16 Mike Stump <mrs@apple.com>
* config/darwin.h (LINK_COMMAND_SPEC): Don't do dwarf stuff on

View File

@ -1,3 +1,8 @@
2006-11-17 Jakub Jelinek <jakub@redhat.com>
PR middle-end/29584
* gcc.dg/torture/pr29584.c: New test.
2006-11-17 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/tree-ssa/stdarg-2.c, gcc.dg/tree-ssa/stdarg-4.c:

View File

@ -0,0 +1,28 @@
/* PR middle-end/29584 */
/* { dg-do compile } */
extern void *foo1 (void);
extern void foo2 (void);
extern void foo3 (void *, void *);
extern int foo4 (void);
void
bar (void)
{
int i;
void *s;
for (i = 1; i < 4; i++)
{
if (foo4 ())
foo2 ();
switch (0x8000000UL + i * 0x400)
{
case 0x80000000UL ... 0x80000000UL + 0x3a000000UL - 1:
s = 0;
break;
default:
s = foo1 ();
}
foo3 ((void *) (0x8000000UL + i * 0x400), s);
}
}

View File

@ -934,7 +934,9 @@ simplify_switch_expr (tree stmt)
need_precision = TYPE_PRECISION (ti);
fail = false;
if (TYPE_UNSIGNED (to) && !TYPE_UNSIGNED (ti))
if (! INTEGRAL_TYPE_P (ti))
fail = true;
else if (TYPE_UNSIGNED (to) && !TYPE_UNSIGNED (ti))
fail = true;
else if (!TYPE_UNSIGNED (to) && TYPE_UNSIGNED (ti))
need_precision += 1;