summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-04-16 07:55:57 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-04-16 07:55:57 +0000
commita8a0d56e10efafca5f60841cc48b36e20980c588 (patch)
tree649c5ed590a9bcfcc0ac37c15b11b36688be346a
parentd32d692f9ed6ac6fb0819f844a028cf91ba3bcaa (diff)
downloadgcc-a8a0d56e10efafca5f60841cc48b36e20980c588.tar.gz
2015-04-16 Richard Biener <rguenther@suse.de>
* tree-ssa-ccp.c (likely_value): See if we have operands that are marked as never simulate again and return CONSTANT in this case. * tree-ssa-propagate.c (simulate_stmt): Mark stmts that do not have any operands that will be simulated again as not being simulated again. * gcc.dg/tree-ssa/ssa-ccp-36.c: New testcase. * gcc.dg/tree-ssa/pr37508.c: Adjust. * gfortran.dg/reassoc_6.f: Remove XFAIL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222141 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr37508.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-36.c15
-rw-r--r--gcc/testsuite/gfortran.dg/reassoc_6.f4
-rw-r--r--gcc/tree-ssa-ccp.c10
-rw-r--r--gcc/tree-ssa-propagate.c40
7 files changed, 82 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6571c1f1558..a3a2016c990 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2015-04-16 Richard Biener <rguenther@suse.de>
+
+ * tree-ssa-ccp.c (likely_value): See if we have operands that
+ are marked as never simulate again and return CONSTANT in this
+ case.
+ * tree-ssa-propagate.c (simulate_stmt): Mark stmts that do
+ not have any operands that will be simulated again as
+ not being simulated again.
+
2015-04-15 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (*cmpi<FPCMP:unord><MODEF:mode>_mixed):
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0912b4b571b..2fd765cb110 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-16 Richard Biener <rguenther@suse.de>
+
+ * gcc.dg/tree-ssa/ssa-ccp-36.c: New testcase.
+ * gcc.dg/tree-ssa/pr37508.c: Adjust.
+ * gfortran.dg/reassoc_6.f: Remove XFAIL.
+
2015-04-15 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/alias-decl-22.C: Adjust for error + inform change.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c b/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c
index aea35cc04ed..19b54fe16e9 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c
@@ -21,7 +21,7 @@ int test2 (struct foo2 *x)
{
if (x->i == 0)
return 1;
- else if (x->i == -1)
+ else if (x->i == -1) /* This test is already folded to false by ccp1. */
return 1;
return 0;
}
@@ -44,5 +44,5 @@ int test4 (struct foo2 *x)
return 0;
}
-/* { dg-final { scan-tree-dump-times "Folding" 3 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Folding" 2 "vrp1" } } */
/* { dg-final { cleanup-tree-dump "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-36.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-36.c
new file mode 100644
index 00000000000..bd72fbd6697
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-36.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-ccp1" } */
+
+int foo (int i, int j)
+{
+ int x = 1;
+ int y = i + x;
+ int z = y - i;
+ if (z == 1)
+ return 1;
+ return 2;
+}
+
+/* { dg-final { scan-tree-dump "return 1;" "ccp1" } } */
+/* { dg-final { cleanup-tree-dump "ccp1" } } */
diff --git a/gcc/testsuite/gfortran.dg/reassoc_6.f b/gcc/testsuite/gfortran.dg/reassoc_6.f
index 97a5de8a748..cbc36f5675b 100644
--- a/gcc/testsuite/gfortran.dg/reassoc_6.f
+++ b/gcc/testsuite/gfortran.dg/reassoc_6.f
@@ -16,7 +16,5 @@
return
end
! Verify that offset of the first element is simplified
-! While we understand to combine x + ~x IVOPTs now messes things
-! up by hiding that operation in casts to unsigned.
-! { dg-final { scan-tree-dump-not "~" "optimized" { xfail *-*-* } } }
+! { dg-final { scan-tree-dump-not "~" "optimized" } }
! { dg-final { cleanup-tree-dump "optimized" } }
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index eeae4bfcd35..996296b4e36 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -646,6 +646,7 @@ static ccp_lattice_t
likely_value (gimple stmt)
{
bool has_constant_operand, has_undefined_operand, all_undefined_operands;
+ bool has_nsa_operand;
tree use;
ssa_op_iter iter;
unsigned i;
@@ -668,6 +669,7 @@ likely_value (gimple stmt)
has_constant_operand = false;
has_undefined_operand = false;
all_undefined_operands = true;
+ has_nsa_operand = false;
FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
{
ccp_prop_value_t *val = get_value (use);
@@ -679,6 +681,10 @@ likely_value (gimple stmt)
if (val->lattice_val == CONSTANT)
has_constant_operand = true;
+
+ if (SSA_NAME_IS_DEFAULT_DEF (use)
+ || !prop_simulate_again_p (SSA_NAME_DEF_STMT (use)))
+ has_nsa_operand = true;
}
/* There may be constants in regular rhs operands. For calls we
@@ -751,8 +757,10 @@ likely_value (gimple stmt)
/* We do not consider virtual operands here -- load from read-only
memory may have only VARYING virtual operands, but still be
- constant. */
+ constant. Also we can combine the stmt with definitions from
+ operands whose definitions are not simulated again. */
if (has_constant_operand
+ || has_nsa_operand
|| gimple_references_memory_p (stmt))
return CONSTANT;
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index c3f9d3e1cda..e23da7094a4 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -366,6 +366,7 @@ simulate_stmt (gimple stmt)
FOR_EACH_EDGE (e, ei, bb->succs)
add_control_edge (e);
}
+ return;
}
else if (val == SSA_PROP_INTERESTING)
{
@@ -379,6 +380,45 @@ simulate_stmt (gimple stmt)
if (taken_edge)
add_control_edge (taken_edge);
}
+
+ /* If there are no SSA uses on the stmt whose defs are simulated
+ again then this stmt will be never visited again. */
+ bool has_simulate_again_uses = false;
+ use_operand_p use_p;
+ ssa_op_iter iter;
+ if (gimple_code (stmt) == GIMPLE_PHI)
+ {
+ edge_iterator ei;
+ edge e;
+ tree arg;
+ FOR_EACH_EDGE (e, ei, gimple_bb (stmt)->preds)
+ if (!(e->flags & EDGE_EXECUTABLE)
+ || ((arg = PHI_ARG_DEF_FROM_EDGE (stmt, e))
+ && TREE_CODE (arg) == SSA_NAME
+ && !SSA_NAME_IS_DEFAULT_DEF (arg)
+ && prop_simulate_again_p (SSA_NAME_DEF_STMT (arg))))
+ {
+ has_simulate_again_uses = true;
+ break;
+ }
+ }
+ else
+ FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
+ {
+ gimple def_stmt = SSA_NAME_DEF_STMT (USE_FROM_PTR (use_p));
+ if (!gimple_nop_p (def_stmt)
+ && prop_simulate_again_p (def_stmt))
+ {
+ has_simulate_again_uses = true;
+ break;
+ }
+ }
+ if (!has_simulate_again_uses)
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "marking stmt to be not simulated again\n");
+ prop_set_simulate_again (stmt, false);
+ }
}
/* Process an SSA edge worklist. WORKLIST is the SSA edge worklist to