This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR tree-optimization/35494: [4.4 Regression]: Revision 132991 breaks 483.xalancbmk


We can't fold glocal variables with NULL DECL_INITIAL. I am testing it
on Linux/x86 and Linux/Intel64 as well as 483.xalancbmk. OK to install
if all pass?


H.J.
----
gcc/testsuite/

2008-03-07  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/

2008-03-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR tree-optimization/35494
	* tree-ssa-ccp.c (get_symbol_constant_value): Only fold local
	variables with NULL DECL_INITIAL.

--- gcc/testsuite/g++.dg/tree-ssa/ssa-store-ccp-1.C.local	2008-03-07 06:45:42.000000000 -0800
+++ gcc/testsuite/g++.dg/tree-ssa/ssa-store-ccp-1.C	2008-03-07 06:44:53.000000000 -0800
@@ -0,0 +1,19 @@
+/* { 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 is
+   global.  */
+/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c.local	2008-03-07 06:58:07.000000000 -0800
+++ gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c	2008-03-07 06:58:38.000000000 -0800
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+const int conststaticvariable;
+
+int f(void)
+{
+  return conststaticvariable;
+}
+
+/* There should be 1 reference to conststaticvariable since it is
+   global.  */
+/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
--- gcc/tree-ssa-ccp.c.local	2008-03-06 14:18:27.000000000 -0800
+++ gcc/tree-ssa-ccp.c	2008-03-07 06:21:57.000000000 -0800
@@ -306,9 +306,10 @@ get_symbol_constant_value (tree sym)
       if (val
 	  && ccp_decl_initial_min_invariant (val))
 	return val;
-      /* Variables declared 'const' without an initializer
+      /* Local variables declared 'const' without an initializer
 	 have zero as the intializer.  */
       if (!val
+	  && !TREE_PUBLIC (sym)
           && (INTEGRAL_TYPE_P (TREE_TYPE (sym))
 	       || SCALAR_FLOAT_TYPE_P (TREE_TYPE (sym))))
         return fold_convert (TREE_TYPE (sym), integer_zero_node);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]