From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20108 invoked by alias); 7 Mar 2008 15:00:56 -0000 Received: (qmail 20096 invoked by uid 22791); 7 Mar 2008 15:00:55 -0000 X-Spam-Check-By: sourceware.org Received: from el-out-1112.google.com (HELO el-out-1112.google.com) (209.85.162.177) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 07 Mar 2008 15:00:30 +0000 Received: by el-out-1112.google.com with SMTP id s27so557071ele.5 for ; Fri, 07 Mar 2008 07:00:27 -0800 (PST) Received: by 10.140.208.14 with SMTP id f14mr533655rvg.204.1204902027171; Fri, 07 Mar 2008 07:00:27 -0800 (PST) Received: from lucon.org ( [75.61.133.211]) by mx.google.com with ESMTPS id q20sm8926135pog.5.2008.03.07.07.00.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Mar 2008 07:00:25 -0800 (PST) Received: by lucon.org (Postfix, from userid 500) id 724049801C0; Fri, 7 Mar 2008 07:00:23 -0800 (PST) Date: Fri, 07 Mar 2008 15:00:00 -0000 To: gcc-patches@gcc.gnu.org Subject: PATCH: PR tree-optimization/35494: [4.4 Regression]: Revision 132991 breaks 483.xalancbmk Message-ID: <20080307150023.GA8336@lucon.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) From: "H.J. Lu" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg00466.txt.bz2 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 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 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);