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 | |
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')
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-2.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-3.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-5.c | 14 | ||||
-rw-r--r-- | gcc/tree-ssa-pre.c | 52 |
8 files changed, 153 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f360ac..cc1c2ef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +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. + 2006-05-04 Joseph S. Myers <joseph@codesourcery.com> * config/mips/linux64.h (DWARF_OFFSET_SIZE): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 119d4bc..c6077c4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,16 @@ +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 + * 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. + 2006-05-04 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/27285 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c new file mode 100644 index 0000000..0cb6324 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre-details" } */ + +/* From PR27090. */ + +int f(int *a) +{ + int t = *a; + unsigned *b = (unsigned *)a; + int *c = (int*)b; + return *c + t; +} + +/* { dg-final { scan-tree-dump "Replaced \\\(int \\\*\\\) b_.*with a_" "fre" } } */ +/* { dg-final { scan-tree-dump "Replaced \\\*c_.*with t_" "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-2.c new file mode 100644 index 0000000..d1eabf6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre-details" } */ + +/* From PR14287. */ + +short g, h; + +void +foo (long a) +{ + short b = a & 3; + long c = b; + g = c; + h = c; +} + +/* { dg-final { scan-tree-dump "Replaced \\\(short int\\\) c_.*with b_" "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-3.c new file mode 100644 index 0000000..ebc91e7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fwrapv -fdump-tree-fre-details" } */ + +/* From PR14844. */ + +int +foo (int a, int b) +{ + long long aa = a; + long long bb = b; + return aa + bb; +} + +/* { dg-final { scan-tree-dump "Replaced \\\(int\\\) aa_.*with a_" "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c new file mode 100644 index 0000000..0d80f02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre-details" } */ + +/* From PR21608. */ + +#define bool _Bool +static inline bool wrap(bool f) { return f; } +bool bar(bool f) +{ + return wrap(f); +} + +/* { dg-final { scan-tree-dump "Replaced \\\(_Bool\\\) D.*with f_" "fre" } } */ +/* { dg-final { scan-tree-dump "Replaced \\\(int\\\) f_.*with D" "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-5.c new file mode 100644 index 0000000..7ef20c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-5.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre-details" } */ + +/* From PR19792. */ + +int +bar (unsigned int t) +{ + int a = t; + return a == t; +} + +/* { dg-final { scan-tree-dump "Replaced \\\(unsigned int\\\) a_.*with t_" "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */ 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; } } |