]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/50205 (ICE: in code_motion_path_driver, at sel-sched.c:6581...
authorAlexander Monakov <amonakov@ispras.ru>
Tue, 18 Oct 2011 12:36:16 +0000 (16:36 +0400)
committerAlexander Monakov <amonakov@gcc.gnu.org>
Tue, 18 Oct 2011 12:36:16 +0000 (16:36 +0400)
PR rtl-optimization/50205
* sel-sched.c (count_occurrences_1): Simplify on the assumption that
p->x is a register.  Forbid substitution when the same register is
found in a different mode.
(count_occurrences_equiv): Assert that 'what' is a register.

* gcc.dg/pr50205.c: New.

From-SVN: r180135

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

index d026022fadb150bbddf0eb1fe79820dd95449236..674d90567bbdb43f98e0aa2d802c483e5130ab37 100644 (file)
@@ -1,3 +1,11 @@
+2011-10-18  Alexander Monakov  <amonakov@ispras.ru>
+
+       PR rtl-optimization/50205
+       * sel-sched.c (count_occurrences_1): Simplify on the assumption that
+       p->x is a register.  Forbid substitution when the same register is
+       found in a different mode.
+       (count_occurrences_equiv): Assert that 'what' is a register.
+
 2011-10-18  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/50767
index f11faca740aef7e9823c1764584f0d4a0ae4a479..2af01aea99e439c267b1c598179d8fb9f07ee288 100644 (file)
@@ -813,18 +813,12 @@ count_occurrences_1 (rtx *cur_rtx, void *arg)
 {
   rtx_search_arg_p p = (rtx_search_arg_p) arg;
 
-  /* The last param FOR_GCSE is true, because otherwise it performs excessive
-    substitutions like
-       r8 = r33
-       r16 = r33
-    for the last insn it presumes r33 equivalent to r8, so it changes it to
-    r33.  Actually, there's no change, but it spoils debugging.  */
-  if (exp_equiv_p (*cur_rtx, p->x, 0, true))
-    {
-      /* Bail out if we occupy more than one register.  */
-      if (REG_P (*cur_rtx)
-          && HARD_REGISTER_P (*cur_rtx)
-          && hard_regno_nregs[REGNO(*cur_rtx)][GET_MODE (*cur_rtx)] > 1)
+  if (REG_P (*cur_rtx) && REGNO (*cur_rtx) == REGNO (p->x))
+    {
+      /* Bail out if mode is different or more than one register is used.  */
+      if (GET_MODE (*cur_rtx) != GET_MODE (p->x)
+          || (HARD_REGISTER_P (*cur_rtx)
+             && hard_regno_nregs[REGNO(*cur_rtx)][GET_MODE (*cur_rtx)] > 1))
         {
           p->n = 0;
           return 1;
@@ -837,7 +831,6 @@ count_occurrences_1 (rtx *cur_rtx, void *arg)
     }
 
   if (GET_CODE (*cur_rtx) == SUBREG
-      && REG_P (p->x)
       && (!REG_P (SUBREG_REG (*cur_rtx))
          || REGNO (SUBREG_REG (*cur_rtx)) == REGNO (p->x)))
     {
@@ -859,6 +852,7 @@ count_occurrences_equiv (rtx what, rtx where)
 {
   struct rtx_search_arg arg;
 
+  gcc_assert (REG_P (what));
   arg.x = what;
   arg.n = 0;
 
index 411f63e8c43dfedd0456d78c3af4579ccc663c16..a883aa5979e58b0ae9a4ee153a26afbf01560086 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-18  Alexander Monakov  <amonakov@ispras.ru>
+
+       PR rtl-optimization/50205
+       * gcc.dg/pr50205.c: New.
+
 2011-10-18  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/50767
diff --git a/gcc/testsuite/gcc.dg/pr50205.c b/gcc/testsuite/gcc.dg/pr50205.c
new file mode 100644 (file)
index 0000000..ff523d0
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fno-cprop-registers -fno-dce -fno-forward-propagate -fselective-scheduling2 -funroll-loops -fno-web" } */
+extern int a[];
+
+void foo (void)
+{
+  int i;
+  for (i = 0; i < 199; i++)
+    {
+      if (a[i] != i)
+       __builtin_abort ();
+    }
+}