[patch] Fix PR rtl-optimization/20017 - Take 2

Kazu Hirata kazu@cs.umass.edu
Wed Feb 23 11:36:00 GMT 2005


Hi Jeff,

> > /* { dg-do compile } */
> > /* { dg-options "-O1" } */
> > /* { dg-options "-O1 -march=i386" { target { i?86-*-* && ilp32 } } } */
> Looks fine to me.

Here is the final patch that I just committed.

Kazu Hirata

2005-02-22  Kazu Hirata  <kazu@cs.umass.edu>

	PR rtl-optimization/20017.
	* passes.c (rest_of_handle_combine, rest_of_handle_cse,
	rest_of_handle_cse2, rest_of_handle_gcse): Call
	delete_dead_jumptables immediately before calling cleanup_cfg.

2005-02-22  Kazu Hirata  <kazu@cs.umass.edu>

	PR rtl-optimization/20017.
	* gcc.dg/pr20017.c: New.

Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.71
diff -u -d -p -r2.71 passes.c
--- passes.c	15 Feb 2005 18:56:44 -0000	2.71
+++ passes.c	22 Feb 2005 18:23:25 -0000
@@ -895,6 +895,7 @@ rest_of_handle_combine (void)
       rebuild_jump_labels (get_insns ());
       timevar_pop (TV_JUMP);
 
+      delete_dead_jumptables ();
       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
     }
 
@@ -971,6 +972,9 @@ rest_of_handle_cse (void)
      expecting CSE to be run.  But always rerun it in a cheap mode.  */
   cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
 
+  if (tem)
+    delete_dead_jumptables ();
+
   if (tem || optimize > 1)
     cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
 
@@ -1006,6 +1010,7 @@ rest_of_handle_cse2 (void)
     {
       timevar_push (TV_JUMP);
       rebuild_jump_labels (get_insns ());
+      delete_dead_jumptables ();
       cleanup_cfg (CLEANUP_EXPENSIVE);
       timevar_pop (TV_JUMP);
     }
@@ -1053,6 +1058,7 @@ rest_of_handle_gcse (void)
     {
       timevar_push (TV_JUMP);
       rebuild_jump_labels (get_insns ());
+      delete_dead_jumptables ();
       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
       timevar_pop (TV_JUMP);
     }
--- /dev/null	2005-02-20 05:55:40.284481520 -0500
+++ testsuite/gcc.dg/pr20017.c	2005-02-22 20:23:30.032206408 -0500
@@ -0,0 +1,41 @@
+/* PR rtl-optimization/20017
+
+   After CSE/GCSE folds a switch statement to an unconditonal jump,
+   cfg_cleanup did not remove a dead jump table, confusing the CFG
+   layout code later on.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+/* { dg-options "-O1 -march=i386" { target { i?86-*-* && ilp32 } } } */
+
+int
+foo (int *buf, int *p)
+{
+  int result;
+  const int *tmp;
+
+  if (*buf)
+    return 1;
+
+  result = 2;
+  *buf = 2;
+  tmp = buf;
+  switch (*tmp)
+    {
+    case 3:
+    case 4:
+    case 6:
+    case 14:
+      return 1;
+
+    case 0:
+      result = *p;
+
+      /* Fall through.  */
+    default:
+      if (result)
+	return 1;
+    }
+
+  return 0;
+}



More information about the Gcc-patches mailing list