From patchwork Mon Feb 14 19:04: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: 83149 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 2791AB7103 for ; Tue, 15 Feb 2011 06:04:41 +1100 (EST) Received: (qmail 17467 invoked by alias); 14 Feb 2011 19:04:38 -0000 Received: (qmail 17456 invoked by uid 22791); 14 Feb 2011 19:04:37 -0000 X-SWARE-Spam-Status: No, hits=-4.3 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; Mon, 14 Feb 2011 19:04:31 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 14 Feb 2011 11:04:30 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by fmsmga002.fm.intel.com with ESMTP; 14 Feb 2011 11:04:30 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 3F016180B21; Mon, 14 Feb 2011 11:04:30 -0800 (PST) Date: Mon, 14 Feb 2011 11:04:30 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: [x32] PATCH: PR middle-end/47727: [x32] Many passes can't handle const symbol when Pmode != ptr_mode Message-ID: <20110214190430.GA13093@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline 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 Hi, simplify-rtx emits new instuctions when Pmode != ptr_mode. This patch avoids it by permuting the conversion and addition when one operand is a constant. Does it make any senses? Thanks. H.J. diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32 index d3c2ac7..c8ead38 100644 --- a/gcc/ChangeLog.x32 +++ b/gcc/ChangeLog.x32 @@ -1,5 +1,11 @@ 2011-02-14 H.J. Lu + PR middle-end/47727 + * explow.c (convert_memory_address_addr_space): Permute the + conversion and addition if one operand is a constant. + +2011-02-14 H.J. Lu + PR middle-end/47725 * function.c (assign_parm_setup_reg): Copy the hard register first before extending it. diff --git a/gcc/explow.c b/gcc/explow.c index 2a18206..593aae3 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -383,18 +383,13 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED, case PLUS: case MULT: - /* For addition we can safely permute the conversion and addition - operation if one operand is a constant and converting the constant - does not change it or if one operand is a constant and we are - using a ptr_extend instruction (POINTERS_EXTEND_UNSIGNED < 0). - We can always safely permute them if we are making the address - narrower. */ + /* For addition we safely permute the conversion and addition + operation if one operand is a constant since we can't generate + new instructions. We can always safely permute them if we are + making the address narrower. */ if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode) || (GET_CODE (x) == PLUS - && CONST_INT_P (XEXP (x, 1)) - && (XEXP (x, 1) == convert_memory_address_addr_space - (to_mode, XEXP (x, 1), as) - || POINTERS_EXTEND_UNSIGNED < 0))) + && CONST_INT_P (XEXP (x, 1)))) return gen_rtx_fmt_ee (GET_CODE (x), to_mode, convert_memory_address_addr_space (to_mode, XEXP (x, 0), as), diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32 index 0085662..27543f8 100644 --- a/gcc/testsuite/ChangeLog.x32 +++ b/gcc/testsuite/ChangeLog.x32 @@ -1,3 +1,8 @@ +2011-02-14 H.J. Lu + + PR middle-end/47727 + * gcc.dg/pr47727.c: New. + 2011-02-13 H.J. Lu PR middle-end/47725 diff --git a/gcc/testsuite/gcc.dg/pr47727.c b/gcc/testsuite/gcc.dg/pr47727.c new file mode 100644 index 0000000..1ce7c36 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr47727.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef void (*func_ptr) (void); +static func_ptr __CTOR_END__[1] = { (func_ptr) 0 }; +static void __attribute__((used)) +__do_global_ctors_aux (void) +{ + func_ptr *p; + for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--) + (*p) (); +}