aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr61607.c29
-rw-r--r--gcc/tree-ssa-threadedge.c37
4 files changed, 67 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 70f8088..61df10d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4191a97..4c4b683 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61607.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61607.c
new file mode 100644
index 0000000..924d686
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61607.c
@@ -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" } } */
+
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. */