diff options
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 912c505..1e2309a 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1317,7 +1317,14 @@ fold_const_aggregate_ref (tree t) if (DECL_P (base) && !AGGREGATE_TYPE_P (TREE_TYPE (base)) && integer_zerop (TREE_OPERAND (t, 1))) - return get_symbol_constant_value (base); + { + tree res = get_symbol_constant_value (base); + if (res + && !useless_type_conversion_p + (TREE_TYPE (t), TREE_TYPE (res))) + res = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (t), res); + return res; + } if (!TREE_READONLY (base) || TREE_CODE (TREE_TYPE (base)) != ARRAY_TYPE |