mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-08 19:31:06 +08:00
tree-ssa-threadedge.c (simplify_control_stmt_condition): Look deeper into the SSA_NAME_VALUE chain.
tree-optimization/61607 * tree-ssa-threadedge.c (simplify_control_stmt_condition): Look deeper into the SSA_NAME_VALUE chain. tree-optimization/61607 * gcc.dg/tree-ssa/pr61607.c: New test. From-SVN: r212149
This commit is contained in:
parent
6a7253a4a9
commit
4f82fed2f6
@ -1,3 +1,9 @@
|
||||
2014-06-30 Jeff Law <law@redhat.com>
|
||||
|
||||
PR tree-optimization/61607
|
||||
* tree-ssa-threadedge.c (simplify_control_stmt_condition): Look
|
||||
deeper into the SSA_NAME_VALUE chain.
|
||||
|
||||
2014-06-30 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* convert.c (convert_to_integer): Don't instrument conversions if the
|
||||
|
@ -1,3 +1,8 @@
|
||||
2014-06-30 Jeff Law <law@redhat.com>
|
||||
|
||||
PR tree-optimization/61607
|
||||
* gcc.dg/tree-ssa/pr61607.c: New test.
|
||||
|
||||
2014-06-30 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* c-c++-common/ubsan/attrib-2.c: New test.
|
||||
|
29
gcc/testsuite/gcc.dg/tree-ssa/pr61607.c
Normal file
29
gcc/testsuite/gcc.dg/tree-ssa/pr61607.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Os -fno-tree-fre -fdump-tree-dom1" } */
|
||||
|
||||
void foo(int *);
|
||||
void f2(int dst[3], int R)
|
||||
{
|
||||
int i, inter[2];
|
||||
_Bool inter0p = 0;
|
||||
_Bool inter1p = 0;
|
||||
for (i = 1; i < R; i++)
|
||||
{
|
||||
inter0p = 1;
|
||||
inter1p = 1;
|
||||
}
|
||||
if (inter0p)
|
||||
inter[0] = 1;
|
||||
if (inter1p)
|
||||
inter[1] = 1;
|
||||
foo(inter);
|
||||
}
|
||||
|
||||
|
||||
/* There should be precisely two conditionals. One for the loop condition
|
||||
and one for the test after the loop. Previously we failed to eliminate
|
||||
the second conditional after the loop. */
|
||||
/* { dg-final { scan-tree-dump-times "if" 2 "dom1"} } */
|
||||
|
||||
/* { dg-final { cleanup-tree-dump "dom1" } } */
|
||||
|
@ -542,16 +542,26 @@ simplify_control_stmt_condition (edge e,
|
||||
/* Get the current value of both operands. */
|
||||
if (TREE_CODE (op0) == SSA_NAME)
|
||||
{
|
||||
tree tmp = SSA_NAME_VALUE (op0);
|
||||
if (tmp)
|
||||
op0 = tmp;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (TREE_CODE (op0) == SSA_NAME
|
||||
&& SSA_NAME_VALUE (op0))
|
||||
op0 = SSA_NAME_VALUE (op0);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (TREE_CODE (op1) == SSA_NAME)
|
||||
{
|
||||
tree tmp = SSA_NAME_VALUE (op1);
|
||||
if (tmp)
|
||||
op1 = tmp;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (TREE_CODE (op1) == SSA_NAME
|
||||
&& SSA_NAME_VALUE (op1))
|
||||
op1 = SSA_NAME_VALUE (op1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (handle_dominating_asserts)
|
||||
@ -625,10 +635,17 @@ simplify_control_stmt_condition (edge e,
|
||||
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 (cached_lhs)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (TREE_CODE (cached_lhs) == SSA_NAME
|
||||
&& SSA_NAME_VALUE (cached_lhs))
|
||||
cached_lhs = SSA_NAME_VALUE (cached_lhs);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we're dominated by a suitable ASSERT_EXPR, then
|
||||
update CACHED_LHS appropriately. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user