+2008-03-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR tree-optimization/35494
+ * tree-ssa-ccp.c (get_symbol_constant_value): Check if value
+ may be overriden at link and run time.
+
2008-03-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/34677
+2008-03-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR tree-optimization/35494
+ * g++.dg/tree-ssa/ssa-store-ccp-1.C: New.
+ * gcc.dg/tree-ssa/ssa-store-ccp-2.c: Likewise.
+ * gcc.dg/tree-ssa/ssa-store-ccp-3.c: Likewise.
+ * gcc.dg/tree-ssa/ssa-store-ccp-4.c: Likewise.
+
2008-03-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/34677
- * tree-ssa-pre.c (modify_expr_node_pool): Remove.
- (poolify_tree): Likewise.
- (modify_expr_template): Likewise.
- (poolify_modify_stmt): Likewise.
- (insert_fake_stores): Handle all component-ref style stores
- in addition to INDIRECT_REF. Also handle complex types.
- Do not poolify the inserted load.
- (realify_fake_stores): Do not rebuild the tree but only
- make it a SSA_NAME copy.
- (init_pre): Remove initialzation of modify_expr_template.
- Do not allocate modify_expr_node_pool.
- (fini_pre): Do not free modify_expr_node_pool.
-
* gcc.dg/tree-ssa/loadpre23.c: New testcase.
* gcc.dg/tree-ssa/loadpre24.c: Likewise.
* gcc.dg/tree-ssa/loadpre25.c: Likewise.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+class bar
+{
+public:
+ static const int conststaticvariable;
+};
+
+
+int f(void)
+{
+ return bar::conststaticvariable;
+}
+
+/* There should be a reference to conststaticvariable since it may
+ be overriden at link time. */
+/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+const int conststaticvariable;
+
+int f(void)
+{
+ return conststaticvariable;
+}
+
+/* There should be a reference to conststaticvariable since it may
+ may be overriden at link time. */
+/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-common -fdump-tree-optimized" } */
+
+const int conststaticvariable;
+
+int f(void)
+{
+ return conststaticvariable;
+}
+
+/* There should be no reference to conststaticvariable as we should have
+ inlined the 0. */
+/* { dg-final { scan-tree-dump-times "conststaticvariable" 0 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O2 -fno-common -fpic -fdump-tree-optimized" } */
+
+const int conststaticvariable;
+
+int f(void)
+{
+ return conststaticvariable;
+}
+
+/* There should be a reference to conststaticvariable since it may
+ may be overriden at run time. */
+/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
{
if (TREE_STATIC (sym)
&& TREE_READONLY (sym)
- && !MTAG_P (sym))
+ && !MTAG_P (sym)
+ /* Check if a read-only definition may be overridden at
+ link and run time. */
+ && targetm.binds_local_p (sym))
{
tree val = DECL_INITIAL (sym);
if (val