aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-threadedge.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2014-06-30 08:08:50 -0600
committerJeff Law <law@gcc.gnu.org>2014-06-30 08:08:50 -0600
commit4f82fed2f6dcef2719103a5fd885f6baf9714ce0 (patch)
tree7d30196f8f6b6532d8b2f5d5c29c5fa282e12b31 /gcc/tree-ssa-threadedge.c
parent6a7253a4a9d6087827414eeee7036d9eb4b1e472 (diff)
downloadgcc-4f82fed2f6dcef2719103a5fd885f6baf9714ce0.zip
gcc-4f82fed2f6dcef2719103a5fd885f6baf9714ce0.tar.gz
gcc-4f82fed2f6dcef2719103a5fd885f6baf9714ce0.tar.bz2
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
Diffstat (limited to 'gcc/tree-ssa-threadedge.c')
-rw-r--r--gcc/tree-ssa-threadedge.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index a76a7ce..9807b42 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -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. */