re PR rtl-optimization/50380 ([4.6 only] cc1 hangs eating 100% CPU)
authorSandra Loosemore <sandra@codesourcery.com>
Mon, 19 Dec 2011 20:29:21 +0000 (15:29 -0500)
committerSandra Loosemore <sandra@gcc.gnu.org>
Mon, 19 Dec 2011 20:29:21 +0000 (15:29 -0500)
2011-12-19  Sandra Loosemore  <sandra@codesourcery.com>
    Tom de Vries <tom@codesourcery.com>

PR rtl-opt/50380

gcc/
* cse.c (find_comparison_args): Detect fixed point and
bail early.

gcc/testsuite/
* gcc.c-torture/compile/pr50380.c: New testcase.

Co-Authored-By: Tom de Vries <tom@codesourcery.com>
From-SVN: r182498

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr50380.c [new file with mode: 0644]

index c2680c6..02c8dce 100644 (file)
@@ -1,3 +1,10 @@
+2011-12-19  Sandra Loosemore  <sandra@codesourcery.com>
+           Tom de Vries <tom@codesourcery.com>
+
+       PR rtl-opt/50380
+       * cse.c (find_comparison_args): Detect fixed point and
+       bail early.
+
 2011-12-19  Aldy Hernandez  <aldyh@redhat.com>
 
        PR middle-end/51411
index ae67685..e624b28 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3055,6 +3055,12 @@ find_comparison_args (enum rtx_code code, rtx *parg1, rtx *parg2,
          if (! exp_equiv_p (p->exp, p->exp, 1, false))
            continue;
 
+         /* If it's the same comparison we're already looking at, skip it.  */
+         if (COMPARISON_P (p->exp)
+             && XEXP (p->exp, 0) == arg1
+             && XEXP (p->exp, 1) == arg2)
+           continue;
+
          if (GET_CODE (p->exp) == COMPARE
              /* Another possibility is that this machine has a compare insn
                 that includes the comparison code.  In that case, ARG1 would
index 701fce8..cf758f1 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-19  Sandra Loosemore  <sandra@codesourcery.com>
+           Tom de Vries <tom@codesourcery.com>
+
+       PR rtl-opt/50380
+       * gcc.c-torture/compile/pr50380.c: New testcase.
+
 2011-12-19  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/51605
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr50380.c b/gcc/testsuite/gcc.c-torture/compile/pr50380.c
new file mode 100644 (file)
index 0000000..ffd0442
--- /dev/null
@@ -0,0 +1,12 @@
+/* This test used to get stuck in an infinite loop in find_comparison_args
+   when compiling for MIPS at -O2.  */
+
+__attribute__ ((__noreturn__)) extern void fail (void);
+
+char x;
+
+void foo (const unsigned char y)
+{
+   ((void) (__builtin_expect((!! y == y), 1) ? 0 : (fail (), 0)));
+   x = ! y;
+}