Commit 8a474dc5 by Richard Biener Committed by Richard Biener

tree-ssa-ccp.c (likely_value): See if we have operands that are marked as never…

tree-ssa-ccp.c (likely_value): See if we have operands that are marked as never simulate again and return...

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.

From-SVN: r222141
parent 8d1cac07
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):
......
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.
......
......@@ -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" } } */
/* { 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" } } */
......@@ -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" } }
......@@ -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;
......
......@@ -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
......
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