PR middle-end/29584
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Nov 2006 08:57:45 +0000 (08:57 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Nov 2006 08:57:45 +0000 (08:57 +0000)
* tree-ssa-forwprop.c (simplify_switch_expr): Don't
optimize if DEF doesn't have integral type.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118921 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr29584.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.c

index 8a74dde..968e679 100644 (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
index c587096..6ba65d4 100644 (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:
diff --git a/gcc/testsuite/gcc.dg/torture/pr29584.c b/gcc/testsuite/gcc.dg/torture/pr29584.c
new file mode 100644 (file)
index 0000000..84bfddc
--- /dev/null
@@ -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);
+    }
+}
index e2c5ed4..a3caf23 100644 (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;