diff options
author | Richard Guenther <rguenther@suse.de> | 2006-05-04 13:56:52 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2006-05-04 13:56:52 +0000 |
commit | d818832cdd9b5cb760cedee68973122571fef418 (patch) | |
tree | 6d24795e20725440defd44c1ddfb42297faca758 /gcc/tree-ssa-pre.c | |
parent | 4f72054bca49e903fd3e01ad86f25d0c5ae391e8 (diff) | |
download | gcc-d818832cdd9b5cb760cedee68973122571fef418.zip gcc-d818832cdd9b5cb760cedee68973122571fef418.tar.gz gcc-d818832cdd9b5cb760cedee68973122571fef418.tar.bz2 |
re PR tree-optimization/14287 ([tree-ssa] does not remove unnecessary extensions)
2006-05-04 Richard Guenther <rguenther@suse.de>
PR tree-optimization/14287
PR tree-optimization/14844
PR tree-optimization/19792
PR tree-optimization/21608
PR tree-optimization/27090
* tree-ssa-pre.c (try_combine_conversion): New function.
(compute_avail): After constructing the value-handle
expression, use try_combine_conversion to combine NOP_EXPRs
with previous value-handle expressions and use the result if it
is available.
* gcc.dg/tree-ssa/ssa-fre-1.c: New testcase.
* gcc.dg/tree-ssa/ssa-fre-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-4.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-5.c: Likewise.
From-SVN: r113527
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r-- | gcc/tree-ssa-pre.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 38f020f..08f0930 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3309,6 +3309,42 @@ realify_fake_stores (void) } } +/* Tree-combine a value number expression *EXPR_P that does a type + conversion with the value number expression of its operand. + Returns true, if *EXPR_P simplifies to a value number or + gimple min-invariant expression different from EXPR_P and + sets *EXPR_P to the simplified expression value number. + Otherwise returns false and does not change *EXPR_P. */ + +static bool +try_combine_conversion (tree *expr_p) +{ + tree expr = *expr_p; + tree t; + + if (!((TREE_CODE (expr) == NOP_EXPR + || TREE_CODE (expr) == CONVERT_EXPR) + && TREE_CODE (TREE_OPERAND (expr, 0)) == VALUE_HANDLE + && !VALUE_HANDLE_VUSES (TREE_OPERAND (expr, 0)))) + return false; + + t = fold_unary (TREE_CODE (expr), TREE_TYPE (expr), + VALUE_HANDLE_EXPR_SET (TREE_OPERAND (expr, 0))->head->expr); + + /* Disallow value expressions we have no value number for already, as + we would miss a leader for it here. */ + if (t + && !(TREE_CODE (t) == VALUE_HANDLE + || is_gimple_min_invariant (t))) + t = vn_lookup (t, NULL); + + if (t && t != expr) + { + *expr_p = t; + return true; + } + return false; +} /* Compute the AVAIL set for all basic blocks. @@ -3433,9 +3469,19 @@ compute_avail (void) tree newt = create_value_expr_from (rhs, block, stmt); if (newt) { - add_to_sets (lhs, newt, stmt, TMP_GEN (block), - AVAIL_OUT (block)); - value_insert_into_set (EXP_GEN (block), newt); + /* If we can combine a conversion expression + with the expression for its operand just + record the value number for it. */ + if (try_combine_conversion (&newt)) + vn_add (lhs, newt); + else + { + tree val = vn_lookup_or_add (newt, stmt); + vn_add (lhs, val); + value_insert_into_set (EXP_GEN (block), newt); + } + bitmap_insert_into_set (TMP_GEN (block), lhs); + bitmap_value_insert_into_set (AVAIL_OUT (block), lhs); continue; } } |