From 61864771af6d7a5834f9df225b4ddd5542d656b0 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Fri, 10 Feb 2006 12:22:58 -0700 Subject: [PATCH] re PR tree-optimization/26213 (new (within last few days) infinite loop with -O1) PR tree-optimization/26213 * tree-ssa-threadedge.c (simplify_control_stmt_condition): Do not loop trying to follow SSA_NAME_VALUE chains. * gcc.c-torture/compile/pr26213.c: New test. From-SVN: r110846 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/compile/pr26213.c | 15 +++++++++++++++ gcc/tree-ssa-threadedge.c | 12 ++++++++---- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr26213.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 59f26709d6f..e9225a4faf8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-02-10 Jeff Law + + PR tree-optimization/26213 + * tree-ssa-threadedge.c (simplify_control_stmt_condition): Do not + loop trying to follow SSA_NAME_VALUE chains. + 2006-02-10 Richard Guenther * tree-dfa.c (get_ref_base_and_extent): When computing maxsize diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28b84e43829..b158d4a292d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2006-02-10 Jeff Law + + * gcc.c-torture/compile/pr26213.c: New test. + 2006-02-10 Steven G. Kargl gfortran.dg/null_1.f90: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr26213.c b/gcc/testsuite/gcc.c-torture/compile/pr26213.c new file mode 100644 index 00000000000..7a6600c18d5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr26213.c @@ -0,0 +1,15 @@ +void +xnanosleep (_Bool overflow) +{ + struct { int tv_nsec; } ts_sleep; + if (0 <= ts_sleep.tv_nsec) + overflow |= 1; + + for (;;) + { + if (overflow) + ts_sleep.tv_nsec = 0; + if (foo (ts_sleep)) + break; + } +} diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index b8d4b1301c6..cc98867b6ec 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -441,10 +441,14 @@ simplify_control_stmt_condition (edge e, { cached_lhs = cond; - /* Get the variable's current value from the equivalency chains. */ - while (cached_lhs - && TREE_CODE (cached_lhs) == SSA_NAME - && SSA_NAME_VALUE (cached_lhs)) + /* Get the variable's current value from the equivalency chains. + + It is possible to get loops in the SSA_NAME_VALUE chains + (consider threading the backedge of a loop where we have + a loop invariant SSA_NAME used in the condition. */ + if (cached_lhs + && TREE_CODE (cached_lhs) == SSA_NAME + && SSA_NAME_VALUE (cached_lhs)) cached_lhs = SSA_NAME_VALUE (cached_lhs); /* If we're dominated by a suitable ASSERT_EXPR, then -- 2.30.2