Commit 236aff72 by Richard Biener Committed by Richard Biener

re PR c/61779 (gcc -Og fails with impossible constraint on legal C code)

2014-07-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/61779
	* tree-ssa-copy.c (copy_prop_visit_cond_stmt): Always try
	simplifying a condition.

	* gcc.dg/tree-ssa/ssa-copyprop-2.c: New testcase.

From-SVN: r212521
parent 72602c6c
2014-07-14 Richard Biener <rguenther@suse.de> 2014-07-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/61779
* tree-ssa-copy.c (copy_prop_visit_cond_stmt): Always try
simplifying a condition.
2014-07-14 Richard Biener <rguenther@suse.de>
* builtins.c (c_strlen): Make only_value == 2 really only * builtins.c (c_strlen): Make only_value == 2 really only
affect warning generation. affect warning generation.
......
2014-07-14 Richard Biener <rguenther@suse.de> 2014-07-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/61779
* gcc.dg/tree-ssa/ssa-copyprop-2.c: New testcase.
2014-07-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/61786 PR tree-optimization/61786
* gcc.dg/torture/pr61786.c: New testcase. * gcc.dg/torture/pr61786.c: New testcase.
* gcc.dg/lto/pr61786_0.c: Likewise. * gcc.dg/lto/pr61786_0.c: Likewise.
......
/* { dg-do compile } */
/* { dg-options "-Og -fdump-tree-optimized" } */
extern long long __sdt_unsp;
void
f(void)
{
for (;;)
__asm__ ("%0" :: "i" (((!__extension__ (__builtin_constant_p ((((unsigned long long) (__typeof (__builtin_choose_expr (((__builtin_classify_type (0) + 3) & -4) == 4, (0), 0U))) __sdt_unsp) ) == 0) )) ? 1 : -1) ));
}
/* { dg-final { scan-tree-dump-not "PHI" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
...@@ -237,38 +237,26 @@ copy_prop_visit_cond_stmt (gimple stmt, edge *taken_edge_p) ...@@ -237,38 +237,26 @@ copy_prop_visit_cond_stmt (gimple stmt, edge *taken_edge_p)
enum ssa_prop_result retval = SSA_PROP_VARYING; enum ssa_prop_result retval = SSA_PROP_VARYING;
location_t loc = gimple_location (stmt); location_t loc = gimple_location (stmt);
tree op0 = gimple_cond_lhs (stmt); tree op0 = valueize_val (gimple_cond_lhs (stmt));
tree op1 = gimple_cond_rhs (stmt); tree op1 = valueize_val (gimple_cond_rhs (stmt));
/* The only conditionals that we may be able to compute statically /* See if we can determine the predicate's value. */
are predicates involving two SSA_NAMEs. */ if (dump_file && (dump_flags & TDF_DETAILS))
if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME)
{ {
op0 = valueize_val (op0); fprintf (dump_file, "Trying to determine truth value of ");
op1 = valueize_val (op1); fprintf (dump_file, "predicate ");
print_gimple_stmt (dump_file, stmt, 0, 0);
/* See if we can determine the predicate's value. */ }
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Trying to determine truth value of ");
fprintf (dump_file, "predicate ");
print_gimple_stmt (dump_file, stmt, 0, 0);
}
/* We can fold COND and get a useful result only when we have /* Fold COND and see whether we get a useful result. */
the same SSA_NAME on both sides of a comparison operator. */ tree folded_cond = fold_binary_loc (loc, gimple_cond_code (stmt),
if (op0 == op1) boolean_type_node, op0, op1);
{ if (folded_cond)
tree folded_cond = fold_binary_loc (loc, gimple_cond_code (stmt), {
boolean_type_node, op0, op1); basic_block bb = gimple_bb (stmt);
if (folded_cond) *taken_edge_p = find_taken_edge (bb, folded_cond);
{ if (*taken_edge_p)
basic_block bb = gimple_bb (stmt); retval = SSA_PROP_INTERESTING;
*taken_edge_p = find_taken_edge (bb, folded_cond);
if (*taken_edge_p)
retval = SSA_PROP_INTERESTING;
}
}
} }
if (dump_file && (dump_flags & TDF_DETAILS) && *taken_edge_p) if (dump_file && (dump_flags & TDF_DETAILS) && *taken_edge_p)
......
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