diff options
author | Richard Guenther <rguenther@suse.de> | 2012-03-14 10:51:34 +0000 |
---|---|---|
committer | Richard Guenther <rguenther@suse.de> | 2012-03-14 10:51:34 +0000 |
commit | 37a1a0d8a6e0ed9b6360f1395ffb3cfb241fc404 (patch) | |
tree | 66df900ef28ae410bf4318c9859d7595727e851a /gcc/tree-ssa-forwprop.c | |
parent | 388cecc0f30cea09f54e862e12675eb7b43c8ad7 (diff) |
2012-03-14 Richard Guenther <rguenther@suse.de>
PR middle-end/52578
* fold-const.c (fold_unary_loc): Fold (T1)(T2)x to (T1)x if
the outermost conversion is a sign-change only.
(fold_binary_loc): Disregard widening and sign-changing
conversions when we determine if two variables are equal
for reassociation.
* tree-ssa-forwprop.c (combine_conversions): Fold (T1)(T2)x to
(T1)x if the outermost conversion is a sign-change only.
* gcc.dg/pr52578.c: New testcase.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@185378 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 20821ef8b98..919779526d9 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -2285,10 +2285,13 @@ combine_conversions (gimple_stmt_iterator *gsi) } /* If we have a sign-extension of a zero-extended value, we can - replace that by a single zero-extension. */ + replace that by a single zero-extension. Likewise if the + final conversion does not change precision we can drop the + intermediate conversion. */ if (inside_int && inter_int && final_int - && inside_prec < inter_prec && inter_prec < final_prec - && inside_unsignedp && !inter_unsignedp) + && ((inside_prec < inter_prec && inter_prec < final_prec + && inside_unsignedp && !inter_unsignedp) + || final_prec == inter_prec)) { gimple_assign_set_rhs1 (stmt, defop0); update_stmt (stmt); |