+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.
{
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;
}
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" } } */
--- /dev/null
+/* { 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" } } */
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" } }
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;
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);
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
/* 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;
FOR_EACH_EDGE (e, ei, bb->succs)
add_control_edge (e);
}
+ return;
}
else if (val == SSA_PROP_INTERESTING)
{
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