cfgcleanup.c (try_optimize_cfg): If try_simplify_condjump optimized conditional jump...
authorJakub Jelinek <jakub@redhat.com>
Thu, 15 Nov 2001 10:41:48 +0000 (11:41 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 15 Nov 2001 10:41:48 +0000 (11:41 +0100)
* cfgcleanup.c (try_optimize_cfg): If try_simplify_condjump optimized
conditional jump, request updating life into for the block
containing it.  Fix a typo which prevented life info update.
Clear blocks bitmap before using it.

* gcc.c-torture/compile/20011114-3.c: New test.

From-SVN: r47050

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20011114-3.c [new file with mode: 0644]

index 010e93eb01bd21beb2e7d01b5fbaf299a268aa01..167bd63590eae7bf148cd002762c0bf1233bc4f5 100644 (file)
 
        * config/ia64/ia64.c (ia64_adjust_cost): Handle SUBREGs.
 
+       * cfgcleanup.c (try_optimize_cfg): If try_simplify_condjump optimized
+       conditional jump, request updating life into for the block
+       containing it.  Fix a typo which prevented life info update.
+       Clear blocks bitmap before using it.
+
 2001-11-15  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * c-common.c: Include c-lex.h.
index 03f767a4df396b1df8c20eb1bd0e0014d830b470..28f3a1fb0c8ee02020653178c7716e0567a19fba 100644 (file)
@@ -1211,7 +1211,10 @@ try_optimize_cfg (mode)
 
          /* Simplify branch over branch.  */
          if ((mode & CLEANUP_EXPENSIVE) && try_simplify_condjump (b))
-           changed_here = true;
+           {
+             BB_SET_FLAG (b, BB_UPDATE_LIFE);
+             changed_here = true;
+           }
 
          /* If B has a single outgoing edge, but uses a non-trivial jump
             instruction without side-effects, we can either delete the
@@ -1261,10 +1264,11 @@ try_optimize_cfg (mode)
   if (mode & CLEANUP_CROSSJUMP)
     remove_fake_edges ();
 
-  if ((mode & CLEANUP_UPDATE_LIFE) & changed_overall)
+  if ((mode & CLEANUP_UPDATE_LIFE) && changed_overall)
     {
       bool found = 0;
       blocks = sbitmap_alloc (n_basic_blocks);
+      sbitmap_zero (blocks);
       for (i = 0; i < n_basic_blocks; i++)
        if (BB_FLAGS (BASIC_BLOCK (i)) & BB_UPDATE_LIFE)
          {
index 38adc49465fac126b4a3671da33e0f92662c791b..1981a9ef20f104c822ba7046f4b50a78d7516b64 100644 (file)
@@ -1,6 +1,7 @@
 2001-11-15  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.c-torture/compile/20011114-2.c: New test.
+       * gcc.c-torture/compile/20011114-3.c: New test.
        * gcc.c-torture/compile/20011114-4.c: New test.
 
 2001-11-15  Nathan Sidwell  <nathan@codesourcery.com>
diff --git a/gcc/testsuite/gcc.c-torture/compile/20011114-3.c b/gcc/testsuite/gcc.c-torture/compile/20011114-3.c
new file mode 100644 (file)
index 0000000..8827925
--- /dev/null
@@ -0,0 +1,42 @@
+typedef struct { int s, t; } C;
+C x;
+int foo (void);
+void bar (int);
+
+int baz (void)
+{
+  int a = 0, c, d = 0;
+  C *b = &x;
+
+  while ((c = foo ()))
+    switch(c)
+      {
+      case 23:
+       bar (1);
+       break;
+      default:
+       break;
+      }
+
+  if (a == 0 || (a & 1))
+    {
+      if (b->s)
+       {
+         if (a)
+           bar (1);
+         else
+           a = 16;
+       }
+      else if (b->t)
+       {
+         if (a)
+           bar (1);
+         else
+           a = 32;
+       }
+    }
+
+  if (d && (a & ~127))
+    bar (2);
+  return 0;
+}