aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-12-04 17:23:27 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-12-04 17:23:27 +0100
commit83b58b6b0e75383fb01cd65b29a8fa1779050269 (patch)
tree1e012432e093346394401bae2a8ceb22a3b7896f
parent8010f31fc7b621810797354bb56093ae171494a3 (diff)
downloadgcc-83b58b6b0e75383fb01cd65b29a8fa1779050269.zip
gcc-83b58b6b0e75383fb01cd65b29a8fa1779050269.tar.gz
gcc-83b58b6b0e75383fb01cd65b29a8fa1779050269.tar.bz2
re PR tree-optimization/68671 (gcc.dg/torture/pr66952.c FAILs with -fno-tree-dce)
PR tree-optimization/68671 * tree-ssa-reassoc.c (maybe_optimize_range_tests): For basic blocks starting with the successor of first bb we've modified and ending with last_bb call reset_flow_sensitive_info_in_bb. * gcc.dg/pr68671.c: New test. From-SVN: r231278
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr68671.c23
-rw-r--r--gcc/tree-ssa-reassoc.c18
4 files changed, 52 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a3bde22..446e74b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-12-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/68671
+ * tree-ssa-reassoc.c (maybe_optimize_range_tests): For basic
+ blocks starting with the successor of first bb we've modified
+ and ending with last_bb call reset_flow_sensitive_info_in_bb.
+
2015-12-04 Jeff Law <law@redhat.com>
* tree-ssa-reassoc.c (maybe_optimize_range_tests): Return boolean
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4b1b1a3..1a037e6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/68671
+ * gcc.dg/pr68671.c: New test.
+
2015-12-02 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/reassoc-43.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr68671.c b/gcc/testsuite/gcc.dg/pr68671.c
new file mode 100644
index 0000000..bec4639
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr68671.c
@@ -0,0 +1,23 @@
+/* PR tree-optimization/68671 */
+/* { dg-do run } */
+/* { dg-options " -O2 -fno-tree-dce" } */
+
+volatile int a = -1;
+volatile int b;
+
+static inline int
+fn1 (signed char p1, int p2)
+{
+ return (p1 < 0) || (p1 > (1 >> p2)) ? 0 : (p1 << 1);
+}
+
+int
+main ()
+{
+ signed char c = a;
+ b = fn1 (c, 1);
+ c = ((128 | c) < 0 ? 1 : 0);
+ if (c != 1)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 315b0bf..e54700e 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -3211,7 +3211,7 @@ maybe_optimize_range_tests (gimple *stmt)
any_changes = optimize_range_tests (ERROR_MARK, &ops);
if (any_changes)
{
- unsigned int idx;
+ unsigned int idx, max_idx = 0;
/* update_ops relies on has_single_use predicates returning the
same values as it did during get_ops earlier. Additionally it
never removes statements, only adds new ones and it should walk
@@ -3227,6 +3227,7 @@ maybe_optimize_range_tests (gimple *stmt)
{
tree new_op;
+ max_idx = idx;
stmt = last_stmt (bb);
new_op = update_ops (bbinfo[idx].op,
(enum tree_code)
@@ -3296,6 +3297,10 @@ maybe_optimize_range_tests (gimple *stmt)
&& ops[bbinfo[idx].first_idx]->op != NULL_TREE)
{
gcond *cond_stmt = as_a <gcond *> (last_stmt (bb));
+
+ if (idx > max_idx)
+ max_idx = idx;
+
/* If we collapse the conditional to a true/false
condition, then bubble that knowledge up to our caller. */
if (integer_zerop (ops[bbinfo[idx].first_idx]->op))
@@ -3320,6 +3325,17 @@ maybe_optimize_range_tests (gimple *stmt)
if (bb == first_bb)
break;
}
+
+ /* The above changes could result in basic blocks after the first
+ modified one, up to and including last_bb, to be executed even if
+ they would not be in the original program. If the value ranges of
+ assignment lhs' in those bbs were dependent on the conditions
+ guarding those basic blocks which now can change, the VRs might
+ be incorrect. As no_side_effect_bb should ensure those SSA_NAMEs
+ are only used within the same bb, it should be not a big deal if
+ we just reset all the VRs in those bbs. See PR68671. */
+ for (bb = last_bb, idx = 0; idx < max_idx; bb = single_pred (bb), idx++)
+ reset_flow_sensitive_info_in_bb (bb);
}
return cfg_cleanup_needed;
}