diff options
author | Richard Guenther <rguenther@suse.de> | 2008-03-03 11:57:15 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-03-03 11:57:15 +0000 |
commit | 9a3277660593535784174ac188b09a151ca9aaee (patch) | |
tree | ce54fd8c85046ba566eb8d22fa71e375248c6f70 /gcc/fold-const.c | |
parent | 6a732743bdccfe0eac5e67d90ef5ee5fe70dfe35 (diff) | |
download | gcc-9a3277660593535784174ac188b09a151ca9aaee.zip gcc-9a3277660593535784174ac188b09a151ca9aaee.tar.gz gcc-9a3277660593535784174ac188b09a151ca9aaee.tar.bz2 |
tree-ssa-sccvn.c (visit_reference_op_store): Do not insert struct copies into the expression table.
2008-03-03 Richard Guenther <rguenther@suse.de>
* tree-ssa-sccvn.c (visit_reference_op_store): Do not insert
struct copies into the expression table.
(simplify_unary_expression): Handle VIEW_CONVERT_EXPR.
(try_to_simplify): Likewise.
* fold-const.c (fold_unary): Fold VIEW_CONVERT_EXPR of
integral and pointer arguments which do not change the
precision to NOP_EXPRs.
* tree-ssa-loop-ivopts.c (may_be_nonaddressable_p): Adjust
VIEW_CONVERT_EXPR case.
From-SVN: r132836
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5af6f0d..6a70e17 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8277,13 +8277,28 @@ fold_unary (enum tree_code code, tree type, tree op0) case VIEW_CONVERT_EXPR: if (TREE_TYPE (op0) == type) return op0; - if (TREE_CODE (op0) == VIEW_CONVERT_EXPR - || (TREE_CODE (op0) == NOP_EXPR - && INTEGRAL_TYPE_P (TREE_TYPE (op0)) - && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0))) - && TYPE_PRECISION (TREE_TYPE (op0)) - == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0))))) + if (TREE_CODE (op0) == VIEW_CONVERT_EXPR) return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0)); + + /* For integral conversions with the same precision or pointer + conversions use a NOP_EXPR instead. */ + if ((INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (op0)) + && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (op0)) + /* Do not muck with VIEW_CONVERT_EXPRs that convert from + a sub-type to its base type as generated by the Ada FE. */ + && !TREE_TYPE (TREE_TYPE (op0))) + || (POINTER_TYPE_P (type) && POINTER_TYPE_P (TREE_TYPE (op0)))) + return fold_convert (type, op0); + + /* Strip inner integral conversions that do not change the precision. */ + if ((TREE_CODE (op0) == NOP_EXPR + || TREE_CODE (op0) == CONVERT_EXPR) + && INTEGRAL_TYPE_P (TREE_TYPE (op0)) + && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0))) + && (TYPE_PRECISION (TREE_TYPE (op0)) + == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0))))) + return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0)); + return fold_view_convert_expr (type, op0); case NEGATE_EXPR: |