From patchwork Mon Jun 20 15:04:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 101139 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 064A2B6F6C for ; Tue, 21 Jun 2011 01:04:59 +1000 (EST) Received: (qmail 26535 invoked by alias); 20 Jun 2011 15:04:57 -0000 Received: (qmail 26524 invoked by uid 22791); 20 Jun 2011 15:04:56 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST, TW_DB X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Jun 2011 15:04:42 +0000 Received: by qwh5 with SMTP id 5so1280903qwh.20 for ; Mon, 20 Jun 2011 08:04:41 -0700 (PDT) Received: by 10.229.94.202 with SMTP id a10mr1124944qcn.32.1308582281184; Mon, 20 Jun 2011 08:04:41 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id m16sm4179958qck.4.2011.06.20.08.04.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Jun 2011 08:04:38 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 50DEC170C1B4; Tue, 21 Jun 2011 00:34:32 +0930 (CST) Date: Tue, 21 Jun 2011 00:34:32 +0930 From: Alan Modra To: David Edelsohn , gcc-patches@gcc.gnu.org Subject: Re: powerpc64 large-toc vs. reload Message-ID: <20110620150432.GP21332@bubble.grove.modra.org> Mail-Followup-To: David Edelsohn , gcc-patches@gcc.gnu.org References: <20110619140336.GM21332@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes 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 Sun, Jun 19, 2011 at 11:04:12PM -0400, David Edelsohn wrote: > On Sun, Jun 19, 2011 at 10:03 AM, Alan Modra wrote: > > * config/rs6000/rs6000.c (create_TOC_reference): Wrap high part > > of toc-relative address in CONST. > > (rs6000_delegitimize_address): Recognize changed address. > > (rs6000_legitimize_reload_address): Likewise. > > (rs6000_emit_move): Don't force these constants to memory. > > * config/rs6000/rs6000.md (tls_gd, tls_gd_high): Wrap high part of > > toc-relative address in CONST. > > (tls_ld, tls_ld_high, tls_got_dtprel, tls_got_dtprel_high): Likewise. > > (tls_got_tprel, tls_got_tprel_high, largetoc_high): Likewise. > > Okay. I applied this after boostrapping c,c++,fortran,lto and finding no regressions, both on mainline and gcc-4.6. Then I did the same for gcc-4.6-ibm and gcc-4.5-ibm, and discovered an internal compiler error on the gcc-4.5-ibm branch in one fortran testcase. Arrgh! This was due to reload putting one of the new CONST patterns in the constant pool. I'm almost certain this can happen on mainline and 4.6 too but just doesn't trigger on the testsuite or during bootstrap. So I need to make a followup patch and match the new CONST pattern in rs6000_cannot_force_const_mem. reload.c:CONST_POOL_OK_P will then prevent reload putting these constants into memory. Bootstrapped and regression tested all over again. This is what I'm about to commit. * config/rs6000/rs6000.c (rs6000_cannot_force_const_mem): Match CONST high part large-toc address. (rs6000_tls_referenced_p): Make static. * config/rs6000/rs6000-protos.h (rs6000_tls_referenced_p): Delete. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 175200) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -6045,7 +6045,7 @@ rs6000_legitimize_tls_address (rtx addr, /* Return 1 if X contains a thread-local symbol. */ -bool +static bool rs6000_tls_referenced_p (rtx x) { if (! TARGET_HAVE_TLS) @@ -6059,6 +6059,11 @@ rs6000_tls_referenced_p (rtx x) static bool rs6000_cannot_force_const_mem (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x) { + if (GET_CODE (x) == CONST + && GET_CODE (XEXP (x, 0)) == PLUS + && GET_CODE (XEXP (XEXP (x, 0), 1)) == HIGH) + return true; + return rs6000_tls_referenced_p (x); } Index: gcc/config/rs6000/rs6000-protos.h =================================================================== --- gcc/config/rs6000/rs6000-protos.h (revision 175200) +++ gcc/config/rs6000/rs6000-protos.h (working copy) @@ -171,7 +171,6 @@ extern unsigned int rs6000_dbx_register_ extern void rs6000_emit_epilogue (int); extern void rs6000_emit_eh_reg_restore (rtx, rtx); extern const char * output_isel (rtx *); -extern bool rs6000_tls_referenced_p (rtx); extern void rs6000_aix_asm_output_dwarf_table_ref (char *); The 4.6 patch is a little different due to 4.5 not already having rs6000_cannot_force_const_mem. * config/rs6000/rs6000.c (rs6000_cannot_force_const_mem): New func. (TARGET_CANNOT_FORCE_CONST_MEM): Update definition. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 175201) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -1212,6 +1212,7 @@ static enum machine_mode rs6000_eh_retur static bool rs6000_can_eliminate (const int, const int); static void rs6000_conditional_register_usage (void); static void rs6000_trampoline_init (rtx, tree, rtx); +static bool rs6000_cannot_force_const_mem (rtx); /* Hash table stuff for keeping track of TOC entries. */ @@ -1382,7 +1383,7 @@ static const struct default_options rs60 #define TARGET_HAVE_TLS HAVE_AS_TLS #undef TARGET_CANNOT_FORCE_CONST_MEM -#define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p +#define TARGET_CANNOT_FORCE_CONST_MEM rs6000_cannot_force_const_mem #undef TARGET_DELEGITIMIZE_ADDRESS #define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address @@ -6651,6 +6663,19 @@ rs6000_tls_referenced_p (rtx x) return for_each_rtx (&x, &rs6000_tls_symbol_ref_1, 0); } +/* Implement TARGET_CANNOT_FORCE_CONST_MEM. */ + +static bool +rs6000_cannot_force_const_mem (rtx x) +{ + if (GET_CODE (x) == CONST + && GET_CODE (XEXP (x, 0)) == PLUS + && GET_CODE (XEXP (XEXP (x, 0), 1)) == HIGH) + return true; + + return rs6000_tls_referenced_p (x); +} + /* Return 1 if *X is a thread-local symbol. This is the same as rs6000_tls_symbol_ref except for the type of the unused argument. */