re PR middle-end/19084 (ICE: internal consistency failure)
authorJakub Jelinek <jakub@redhat.com>
Fri, 14 Jan 2005 10:50:18 +0000 (11:50 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 14 Jan 2005 10:50:18 +0000 (11:50 +0100)
PR middle-end/19084
PR rtl-optimization/19348
* recog.c (peephole2_optimize): Do global life update if some peephole
decides it doesn't need at least one of its inputs and that change
influences liveness at the start of the basic block.

* basic-block.h (EXECUTE_IF_AND_COMPL_IN_REG_SET): Needs 2 REGSET
arguments instead of 1.

* gcc.dg/20050111-1.c: New test.
* gcc.c-torture/execute/20050111-1.c: New test.

From-SVN: r93639

gcc/ChangeLog
gcc/basic-block.h
gcc/recog.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20050111-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/20050111-1.c [new file with mode: 0644]

index 9e733219cb9cd5364d30e810a8e958ccfa557dbb..91796254cdc7c52c13b26b139f916ed28bd1d4d1 100644 (file)
@@ -1,3 +1,14 @@
+2005-01-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/19084
+       PR rtl-optimization/19348
+       * recog.c (peephole2_optimize): Do global life update if some peephole
+       decides it doesn't need at least one of its inputs and that change
+       influences liveness at the start of the basic block.
+
+       * basic-block.h (EXECUTE_IF_AND_COMPL_IN_REG_SET): Needs 2 REGSET
+       arguments instead of 1.
+
 2005-01-14  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR middle-end/18820
index 39ce7744ac02167acbea2fb3ffa73d66888d5409..bfeac26d7f762584cd64d64a75bfa4f61835df63 100644 (file)
@@ -98,8 +98,8 @@ typedef bitmap_iterator reg_set_iterator;
 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
    REGNUM to the register number and executing CODE for all registers that are
    set in the first regset and not set in the second.  */
-#define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET, MIN, REGNUM, RSI)      \
-  EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET, MIN, REGNUM, RSI)
+#define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
+  EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI)
 
 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
    REGNUM to the register number and executing CODE for all registers that are
index 09a98f2e33f1e769a7743c41a233b61ad6fa3212..6fc3cf9ad647d4a526799ee133288368e8ed917c 100644 (file)
@@ -2968,6 +2968,7 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
   bool changed;
 #endif
   bool do_cleanup_cfg = false;
+  bool do_global_life_update = false;
   bool do_rebuild_jump_labels = false;
 
   /* Initialize the regsets we're going to use.  */
@@ -2986,6 +2987,8 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
   FOR_EACH_BB_REVERSE (bb)
     {
       struct propagate_block_info *pbi;
+      reg_set_iterator rsi;
+      unsigned int j;
 
       /* Indicate that all slots except the last holds invalid data.  */
       for (i = 0; i < MAX_INSNS_PER_PEEP2; ++i)
@@ -3207,6 +3210,15 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
            break;
        }
 
+      /* Some peepholes can decide the don't need one or more of their
+        inputs.  If this happens, local life update is not enough.  */
+      EXECUTE_IF_AND_COMPL_IN_BITMAP (bb->global_live_at_start, live,
+                                     0, j, rsi)
+       {
+         do_global_life_update = true;
+         break;
+       }
+
       free_propagate_block_info (pbi);
     }
 
@@ -3223,8 +3235,10 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
   if (do_cleanup_cfg)
     {
       cleanup_cfg (0);
-      update_life_info (0, UPDATE_LIFE_GLOBAL_RM_NOTES, PROP_DEATH_NOTES);
+      do_global_life_update = true;
     }
+  if (do_global_life_update)
+    update_life_info (0, UPDATE_LIFE_GLOBAL_RM_NOTES, PROP_DEATH_NOTES);
 #ifdef HAVE_conditional_execution
   else
     {
index 6d606915063708ededa7df75b635f6ea23fa0d68..2d14c7d4e8704980c1fb5756068b075fbd2e0c3a 100644 (file)
@@ -1,5 +1,10 @@
 2005-01-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/19084
+       PR rtl-optimization/19348
+       * gcc.dg/20050111-1.c: New test.
+       * gcc.c-torture/execute/20050111-1.c: New test.
+
        * gcc.dg/i386-asm-4.c: New test.
 
 2005-01-14  Eric Botcazou  <ebotcazou@libertysurf.fr>
diff --git a/gcc/testsuite/gcc.c-torture/execute/20050111-1.c b/gcc/testsuite/gcc.c-torture/execute/20050111-1.c
new file mode 100644 (file)
index 0000000..d6089f1
--- /dev/null
@@ -0,0 +1,39 @@
+/* PR middle-end/19084, rtl-optimization/19348 */
+
+unsigned int
+foo (unsigned long long x)
+{
+  unsigned int u;
+
+  if (x == 0)
+    return 0;
+  u = (unsigned int) (x >> 32);
+  return u;
+}
+
+unsigned long long
+bar (unsigned short x)
+{
+  return (unsigned long long) x << 32;
+}
+
+extern void abort (void);
+
+int
+main (void)
+{
+  if (sizeof (long long) != 8)
+    return 0;
+
+  if (foo (0) != 0)
+    abort ();
+  if (foo (0xffffffffULL) != 0)
+    abort ();
+  if (foo (0x25ff00ff00ULL) != 0x25)
+    abort ();
+  if (bar (0) != 0)
+    abort ();
+  if (bar (0x25) != 0x2500000000ULL)
+    abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/20050111-1.c b/gcc/testsuite/gcc.dg/20050111-1.c
new file mode 100644 (file)
index 0000000..0cc4b7e
--- /dev/null
@@ -0,0 +1,24 @@
+/* PR middle-end/19084, rtl-optimization/19348 */
+/* { dg-do compile } */
+/* The following ensures that this test is compiled with -O2, unless
+   on i?86 or x86_64 with -m32 option.  */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -march=i686" { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2" { target lp64 } } */
+
+unsigned int
+foo (unsigned long long x)
+{
+  unsigned int u;
+
+  if (x == 0)
+    return 0;
+  u = (unsigned int) (x >> 32);
+  return u;
+}
+
+unsigned long long
+bar (unsigned short x)
+{
+  return (unsigned long long) x << 32;
+}