+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.
+
2008-03-27 Zdenek Dvorak <ook@ucw.cz>
* tree-affine.h (aff_combination_expand): Declare.
+2008-03-27 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/32810
+ * gcc.dg/tree-ssa/ssa-ccp-18.c: New testcase.
+
2008-03-27 Douglas Gregor <doug.gregor@gmail.com>
* g++.dg/cpp0x/variadic91.C: New.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-ccp1" } */
+
+/* Check that we constant propagate &&c into the goto and remove
+ the unreachable BBs. */
+
+void a(int*); void b(int*); void c(int*); void d(int*);
+void func2(int* val)
+{
+ const void *const labels[] = { &&a, &&b, &&c, &&d };
+ goto *labels[2];
+ a: a(val);
+ b: b(val);
+ c: c(val);
+ d: d(val);
+}
+
+/* { dg-final { scan-tree-dump-not "a \\\(" "ccp1" } } */
+/* { dg-final { scan-tree-dump-not "b \\\(" "ccp1" } } */
+/* { dg-final { cleanup-tree-dump "ccp1" } } */
&& !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. */
/* 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:
if (cfield == field
/* FIXME: Handle bit-fields. */
&& ! DECL_BIT_FIELD (cfield))
- return cval;
+ {
+ STRIP_USELESS_TYPE_CONVERSION (cval);
+ return cval;
+ }
break;
case REALPART_EXPR: