diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2005-04-13 15:28:55 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2005-04-13 15:28:55 +0000 |
commit | 9fb6cbd90e1a14cdacfa10af31317ddcd70af21f (patch) | |
tree | 1dbb90005a98cf50ebb4b58c851c2129c3c1e1f4 /gcc/tree-ssa-copy.c | |
parent | e22a7bcf2604c5e0b29200530eaa090e787a249b (diff) | |
download | gcc-9fb6cbd90e1a14cdacfa10af31317ddcd70af21f.zip gcc-9fb6cbd90e1a14cdacfa10af31317ddcd70af21f.tar.gz gcc-9fb6cbd90e1a14cdacfa10af31317ddcd70af21f.tar.bz2 |
re PR tree-optimization/20913 (copy-prop does not fold conditionals)
gcc/
PR tree-optimization/20913
* tree-ssa-copy.c (copy_prop_visit_cond_stmt): Fold COND_EXPR.
testsuite/
PR tree-optimization/20913
* gcc.dg/tree-ssa/pr20913.c: New.
From-SVN: r98090
Diffstat (limited to 'gcc/tree-ssa-copy.c')
-rw-r--r-- | gcc/tree-ssa-copy.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index 91d80a7..b9544f8 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -626,9 +626,16 @@ copy_prop_visit_cond_stmt (tree stmt, edge *taken_edge_p) print_generic_stmt (dump_file, cond, 0); } - *taken_edge_p = find_taken_edge (bb_for_stmt (stmt), cond); - if (*taken_edge_p) - retval = SSA_PROP_INTERESTING; + /* We can fold COND only and get a useful result only when we + have the same SSA_NAME on both sides of a comparison + operator. */ + if (TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME + && TREE_OPERAND (cond, 0) == TREE_OPERAND (cond, 1)) + { + *taken_edge_p = find_taken_edge (bb_for_stmt (stmt), fold (cond)); + if (*taken_edge_p) + retval = SSA_PROP_INTERESTING; + } /* Restore the original operands. */ for (i = 0; i < NUM_USES (uses); i++) |