Commit 83b58b6b by Jakub Jelinek Committed by Jakub Jelinek

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
parent 8010f31f
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
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.
......
/* 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;
}
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment