aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-03-27 16:32:28 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-03-27 16:32:28 +0000
commit62bc00e258331aeba39f47e9fee275f4ba5b7956 (patch)
treec628fc1d3e3534745082337d622e3b846f62f870 /gcc/tree-ssa-ccp.c
parent525521b6ddb69a9f0478704e0eec2231c0923d2d (diff)
downloadgcc-62bc00e258331aeba39f47e9fee275f4ba5b7956.zip
gcc-62bc00e258331aeba39f47e9fee275f4ba5b7956.tar.gz
gcc-62bc00e258331aeba39f47e9fee275f4ba5b7956.tar.bz2
re PR tree-optimization/32810 (Not folding of const element for goto)
2008-03-27 Richard Guenther <rguenther@suse.de> PR tree-optimization/32810 * tree-ssa-ccp.c (get_symbol_constant_value): Strip useless conversions from DECL_INITIAL. (fold_const_aggregate_ref): Likewise from constructor elements. * gcc.dg/tree-ssa/ssa-ccp-18.c: New testcase. From-SVN: r133645
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 8dcc759..9bba505 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -278,9 +278,12 @@ get_symbol_constant_value (tree sym)
&& !MTAG_P (sym))
{
tree val = DECL_INITIAL (sym);
- if (val
- && is_gimple_min_invariant (val))
- return val;
+ if (val)
+ {
+ STRIP_USELESS_TYPE_CONVERSION (val);
+ if (is_gimple_min_invariant (val))
+ return val;
+ }
/* Variables declared 'const' without an initializer
have zero as the intializer if they may not be
overridden at link or run time. */
@@ -1104,7 +1107,10 @@ fold_const_aggregate_ref (tree t)
/* Whoo-hoo! I'll fold ya baby. Yeah! */
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), cnt, cfield, cval)
if (tree_int_cst_equal (cfield, idx))
- return cval;
+ {
+ STRIP_USELESS_TYPE_CONVERSION (cval);
+ return cval;
+ }
break;
case COMPONENT_REF:
@@ -1144,7 +1150,10 @@ fold_const_aggregate_ref (tree t)
if (cfield == field
/* FIXME: Handle bit-fields. */
&& ! DECL_BIT_FIELD (cfield))
- return cval;
+ {
+ STRIP_USELESS_TYPE_CONVERSION (cval);
+ return cval;
+ }
break;
case REALPART_EXPR: