re PR rtl-optimization/42294 (ICE in code_motion_path_driver for 416.gamess)
authorAndrey Belevantsev <abel@gcc.gnu.org>
Thu, 14 Jan 2010 10:16:01 +0000 (13:16 +0300)
committerAndrey Belevantsev <abel@gcc.gnu.org>
Thu, 14 Jan 2010 10:16:01 +0000 (13:16 +0300)
        PR rtl-optimization/42294
        * sel-sched.c (try_replace_dest_reg): When chosen register
        and original register is the same, do not bail out early, but
        still check all original insns for validity of replacing destination
        register.  Set EXPR_TARGET_AVAILABLE to 1 before leaving function
        in this case.

From-SVN: r155889

gcc/ChangeLog
gcc/sel-sched.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr42249.c [new file with mode: 0644]

index 8f4c3262d19a54553d8c80a99f7986bffa6cbdfc..b4ebd0b20a3dc420d76efb83d55b29ca39f5d988 100644 (file)
@@ -1,3 +1,12 @@
+2010-01-14  Andrey Belevantsev <abel@ispras.ru>
+
+       PR rtl-optimization/42294
+       * sel-sched.c (try_replace_dest_reg): When chosen register
+       and original register is the same, do not bail out early, but
+       still check all original insns for validity of replacing destination
+       register.  Set EXPR_TARGET_AVAILABLE to 1 before leaving function
+       in this case.
+
 2010-01-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/42721
index e5ebc57387b19a755e936a223b0b5e93575bebe8..27c0f21ea3b38db9a7fd0db62764e868ea8cda26 100644 (file)
@@ -1642,14 +1642,6 @@ collect_unavailable_regs_from_bnds (expr_t expr, blist_t bnds, regset used_regs,
 static bool
 try_replace_dest_reg (ilist_t orig_insns, rtx best_reg, expr_t expr)
 {
-  if (expr_dest_regno (expr) == REGNO (best_reg))
-    {
-      EXPR_TARGET_AVAILABLE (expr) = 1;
-      return true;
-    }
-
-  gcc_assert (orig_insns);
-
   /* Try whether we'll be able to generate the insn
      'dest := best_reg' at the place of the original operation.  */
   for (; orig_insns; orig_insns = ILIST_NEXT (orig_insns))
@@ -1658,14 +1650,19 @@ try_replace_dest_reg (ilist_t orig_insns, rtx best_reg, expr_t expr)
 
       gcc_assert (EXPR_SEPARABLE_P (INSN_EXPR (orig_insn)));
 
-      if (!replace_src_with_reg_ok_p (orig_insn, best_reg)
-         || !replace_dest_with_reg_ok_p (orig_insn, best_reg))
+      if (REGNO (best_reg) != REGNO (INSN_LHS (orig_insn))
+         && (! replace_src_with_reg_ok_p (orig_insn, best_reg)
+             || ! replace_dest_with_reg_ok_p (orig_insn, best_reg)))
        return false;
     }
 
   /* Make sure that EXPR has the right destination
      register.  */
-  replace_dest_with_reg_in_expr (expr, best_reg);
+  if (expr_dest_regno (expr) != REGNO (best_reg))
+    replace_dest_with_reg_in_expr (expr, best_reg);
+  else
+    EXPR_TARGET_AVAILABLE (expr) = 1;
+
   return true;
 }
 
index 0478ae577bc9a62f6d8eb6f8cc22b52bcdba8648..a407fb72536371fc3ed5fe2aeac94c997fdd342f 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-14  Alexander Monakov <amonakov@ispras.ru>
+
+        PR rtl-optimization/42294
+        * gcc.dg/pr42249.c: New.
+
 2010-01-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/42721
diff --git a/gcc/testsuite/gcc.dg/pr42249.c b/gcc/testsuite/gcc.dg/pr42249.c
new file mode 100644 (file)
index 0000000..2170874
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining" } */
+
+typedef struct TypHeader
+{
+  unsigned long size;
+  struct TypHeader **ptr;
+} *TypHandle;
+
+extern TypHandle NewBag (unsigned int type, unsigned long size);
+typedef unsigned long TypPoint32;
+
+TypHandle
+QuoPP (TypHandle hdL, TypHandle hdR)
+{
+  TypHandle hdC;
+  unsigned long degC;
+  TypPoint32 *ptC;
+  unsigned long degL;
+  TypPoint32 *ptL;
+  unsigned long degR;
+  TypPoint32 *ptR;
+  unsigned long p;
+
+  degL = ((hdL)->size) / sizeof (TypPoint32);
+  degR = ((hdR)->size) / sizeof (TypPoint32);
+  degC = degL < degR ? degR : degL;
+  hdC = NewBag (9, (unsigned long) (degC * sizeof (TypPoint32)));
+  ptC = (TypPoint32 *) ((TypHandle *) ((hdC)->ptr));
+
+  for (p = 0; p < degC; p++)
+    ptC[(((p) < (degR)) ? (ptR)[(p)] : (p))] =
+      ((((((p) < (degL)) ? (ptL)[(p)] : (p))) <
+        (degR)) ? (ptR)[((((p) < (degL)) ? (ptL)[(p)] : (p)))]
+       : ((((p) < (degL)) ? (ptL)[(p)] : (p))));
+}
+