From 8f1ad6b6bfd9102bf5e240191f3df95498188410 Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Mon, 19 Dec 2011 15:29:21 -0500 Subject: [PATCH] re PR rtl-optimization/50380 ([4.6 only] cc1 hangs eating 100% CPU) 2011-12-19 Sandra Loosemore Tom de Vries 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 From-SVN: r182498 --- gcc/ChangeLog | 7 +++++++ gcc/cse.c | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.c-torture/compile/pr50380.c | 12 ++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr50380.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c2680c6..02c8dce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-12-19 Sandra Loosemore + Tom de Vries + + PR rtl-opt/50380 + * cse.c (find_comparison_args): Detect fixed point and + bail early. + 2011-12-19 Aldy Hernandez PR middle-end/51411 diff --git a/gcc/cse.c b/gcc/cse.c index ae67685..e624b28 100644 --- 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 701fce8..cf758f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-12-19 Sandra Loosemore + Tom de Vries + + PR rtl-opt/50380 + * gcc.c-torture/compile/pr50380.c: New testcase. + 2011-12-19 Tobias Burnus 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 index 0000000..ffd0442 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr50380.c @@ -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; +} -- 2.7.4