A dumb mistake on my part, we can have a self-referencing definition
statement inside a loop. That will cause the recently added code to
walk back through BIT_IOR_EXPRs to recurse forever.
I've added a trivial recursion depth limit.
Bootstrapped and regression tested on x86_64-linux-gnu. Installed on
the trunk. Sorry for the breakage.
Jeff
commit 602ce767e82ba30364603155d18290f8f02aeded
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue Mar 28 03:22:25 2017 +0000
PR tree-optimization/80162
* tree-ssa-dom.c (derive_equivalences_from_bit_ior): Fix typo in
function name. Limit recursion depth.
(record_temporary_equivalences): Corresponding changes.
PR tree-optimization/80162
* gcc.c-torture/compile/pr80216.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@246517
138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a45168e..10bb56b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+017-03-27 Jeff Law <l...@redhat.com>
+
+ PR tree-optimization/80162
+ * tree-ssa-dom.c (derive_equivalences_from_bit_ior): Fix typo in
+ function name. Limit recursion depth.
+ (record_temporary_equivalences): Corresponding changes.
+
2017-03-27 Jonathan Wakely <jwak...@redhat.com>
* doc/invoke.texi (-Wno-narrowing): Reorder so default behavior is
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 14f6d6b..9c7f2cf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-27 Jeff Law <l...@redhat.com>
+
+ PR tree-optimization/80162
+ * gcc.c-torture/compile/pr80216.c: New test.
+
2017-03-27 Jakub Jelinek <ja...@redhat.com>
PR middle-end/80162
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr80216.c
b/gcc/testsuite/gcc.c-torture/compile/pr80216.c
new file mode 100644
index 0000000..cf5b27d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr80216.c
@@ -0,0 +1,37 @@
+int u4, lx, e0, zy, pz;
+
+void
+tb (int m6)
+{
+ for (pz = 0; pz < 1; ++pz)
+ {
+ for (zy = 0; zy < 1; ++zy)
+ for (u4 = 0; u4 < 1; ++u4)
+ for (e0 = 0; e0 < 1; ++e0)
+ {
+ as:
+ for (;;)
+ {
+ }
+ }
+
+ if (e0 != 0)
+ goto ql;
+
+ if (0)
+ {
+ o3:
+ for (lx = 0; lx < 1; ++lx)
+ {
+ m6 |= lx;
+ if (m6 == 0)
+ lx = 0;
+ ql:
+ ;
+ }
+ goto as;
+ }
+ }
+ goto o3;
+}
+
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index c6ffc38..d2263bb 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -692,11 +692,18 @@ back_propagate_equivalences (tree lhs, edge e,
}
/* Record NAME has the value zero and if NAME was set from a BIT_IOR_EXPR
- recurse into both operands recording their values as zero too. */
+ recurse into both operands recording their values as zero too.
+ RECURSION_DEPTH controls how far back we recurse through the operands
+ of the BIT_IOR_EXPR. */
static void
-derive_equivalencs_from_bit_ior (tree name, const_and_copies *const_and_copies)
+derive_equivalences_from_bit_ior (tree name,
+ const_and_copies *const_and_copies,
+ int recursion_limit)
{
+ if (recursion_limit == 0)
+ return;
+
if (TREE_CODE (name) == SSA_NAME)
{
tree value = fold_convert (TREE_TYPE (name), integer_zero_node);
@@ -710,10 +717,12 @@ derive_equivalencs_from_bit_ior (tree name,
const_and_copies *const_and_copies)
if (is_gimple_assign (def_stmt)
&& gimple_assign_rhs_code (def_stmt) == BIT_IOR_EXPR)
{
- derive_equivalencs_from_bit_ior (gimple_assign_rhs1 (def_stmt),
- const_and_copies);
- derive_equivalencs_from_bit_ior (gimple_assign_rhs2 (def_stmt),
- const_and_copies);
+ derive_equivalences_from_bit_ior (gimple_assign_rhs1 (def_stmt),
+ const_and_copies,
+ recursion_limit - 1);
+ derive_equivalences_from_bit_ior (gimple_assign_rhs2 (def_stmt),
+ const_and_copies,
+ recursion_limit - 1);
}
}
}
@@ -751,7 +760,7 @@ record_temporary_equivalences (edge e,
enum tree_code code = eq->cond.ops.binary.op;
if ((code == EQ_EXPR && eq->value == boolean_true_node)
|| (code == NE_EXPR && eq->value == boolean_false_node))
- derive_equivalencs_from_bit_ior (op0, const_and_copies);
+ derive_equivalences_from_bit_ior (op0, const_and_copies, 4);
/* TODO: We could handle BIT_AND_EXPR in a similar fashion
recording that the operands have a nonzero value. */