From patchwork Wed Mar 2 19:58:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 85132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1559DB6EF7 for ; Thu, 3 Mar 2011 06:58:39 +1100 (EST) Received: (qmail 14860 invoked by alias); 2 Mar 2011 19:58:36 -0000 Received: (qmail 14852 invoked by uid 22791); 2 Mar 2011 19:58:35 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Mar 2011 19:58:31 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 02 Mar 2011 11:58:30 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by fmsmga001.fm.intel.com with ESMTP; 02 Mar 2011 11:58:30 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 22B5F180958; Wed, 2 Mar 2011 11:58:30 -0800 (PST) Date: Wed, 2 Mar 2011 11:58:30 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: Re: RFC: PR rtl-optimization/47958: [x32] reload generates invalid address reference Message-ID: <20110302195830.GA27769@intel.com> Reply-To: "H.J. Lu" References: <20110302172921.GA2302@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110302172921.GA2302@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Wed, Mar 02, 2011 at 09:29:21AM -0800, H.J. Lu wrote: > Hi, > > When we force a symbol reference in the constant pool, it should be > in ptr_mode even if symbol is in Pmode. This patch does it. Does > it make any senses? > Reload should put symbol reference in the constant pool in proper mode. I am testing this patch instead. H.J. diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32 index 497866d..a3b7364 100644 --- a/gcc/ChangeLog.x32 +++ b/gcc/ChangeLog.x32 @@ -1,3 +1,9 @@ +2011-03-02 H.J. Lu + + PR rtl-optimization/47958 + * reload.c (find_reloads): Put symbol reference in memory + in ptr_mode. + 2011-03-01 H.J. Lu PR target/47744 diff --git a/gcc/reload.c b/gcc/reload.c index 714355c3..bf6101f 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -3918,7 +3918,18 @@ find_reloads (rtx insn, int replace, int ind_levels, int live_known, && mode != VOIDmode) { int this_address_reloaded; - rtx tem = force_const_mem (mode, op); + rtx tem; + + /* Symbol reference in the constant pool must be in + ptr_mode. */ + if (subreg != NULL_RTX + && plus == NULL_RTX + && Pmode != ptr_mode + && GET_MODE (subreg) == ptr_mode + && GET_CODE (op) == SYMBOL_REF) + tem = force_const_mem (ptr_mode, op); + else + tem = force_const_mem (mode, op); /* If we stripped a SUBREG or a PLUS above add it back. */ if (plus != NULL_RTX) diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32 index c57f5ca..22345df 100644 --- a/gcc/testsuite/ChangeLog.x32 +++ b/gcc/testsuite/ChangeLog.x32 @@ -1,3 +1,8 @@ +2011-03-02 H.J. Lu + + PR rtl-optimization/47958 + * gcc.dg/torture/pr47958-1.c: New. + 2011-03-01 H.J. Lu PR target/47744 diff --git a/gcc/testsuite/gcc.dg/torture/pr47958-1.c b/gcc/testsuite/gcc.dg/torture/pr47958-1.c new file mode 100644 index 0000000..9fdf142 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr47958-1.c @@ -0,0 +1,13 @@ +/* { dg-do assemble } */ + +void (*foo[6][6]) (int); +void bar (hdR) + int hdR; +{ } +void xxx () +{ + unsigned int i, j; + for (i = 0; i < 6; ++i) + for (j = 0; j < 6; ++j) + foo [i][j] = bar; +}