From patchwork Thu Apr 28 15:22:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 93242 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 DC886B6F54 for ; Fri, 29 Apr 2011 01:22:53 +1000 (EST) Received: (qmail 30390 invoked by alias); 28 Apr 2011 15:22:51 -0000 Received: (qmail 30381 invoked by uid 22791); 28 Apr 2011 15:22:49 -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, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-px0-f176.google.com (HELO mail-px0-f176.google.com) (209.85.212.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Apr 2011 15:22:34 +0000 Received: by pxi11 with SMTP id 11so109621pxi.21 for ; Thu, 28 Apr 2011 08:22:33 -0700 (PDT) Received: by 10.68.18.73 with SMTP id u9mr1765788pbd.347.1304004153766; Thu, 28 Apr 2011 08:22:33 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id z6sm1274594pbp.63.2011.04.28.08.22.31 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Apr 2011 08:22:32 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 4336D170C2B8; Fri, 29 Apr 2011 00:52:27 +0930 (CST) Date: Fri, 29 Apr 2011 00:52:27 +0930 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: David Edelsohn Subject: PowerPC64 non-delegitimized UNSPEC_TOCREL Message-ID: <20110428152227.GL19947@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org, David Edelsohn MIME-Version: 1.0 Content-Disposition: inline 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 This patch fixes the following warnings seen during a powerpc64 bootstrap. libgomp/config/linux/sem.c: In function ‘gomp_sem_wait_slow’: libgomp/config/linux/sem.c:33:1: note: non-delegitimized UNSPEC UNSPEC_TOCREL (44) found in variable location libgomp/config/linux/bar.c: In function ‘gomp_barrier_wait_end’: libgomp/config/linux/bar.c:34:1: note: non-delegitimized UNSPEC UNSPEC_TOCREL (44) found in variable location What's happening is that we are getting an address that looked like lo_sum ((reg 31) (const (plus (unspec [symbol_ref ("some_var") tocrel]) 4))) but only expect to handle something like lo_sum ((reg 31) (const (unspec [symbol_ref ("some_var") tocrel]))) I also tidied the macho code which used a mix of "orig_x" and "x", makeing the code fragile wrt. some future change that assigns "x" earlier in the function. (If orig_x is a lo_sum, then x == orig_x currently.) Bootstrapped and regression tested powerpc64-linux. OK to apply? * config/rs6000/rs6000.c (rs6000_delegitimize_address): Handle unspec plus offset. Tidy macho code. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 173064) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -6380,7 +6380,16 @@ rs6000_delegitimize_address (rtx orig_x) if (GET_CODE (x) == (TARGET_CMODEL != CMODEL_SMALL ? LO_SUM : PLUS) && GET_CODE (XEXP (x, 1)) == CONST) { + rtx offset = NULL_RTX; + y = XEXP (XEXP (x, 1), 0); + if (GET_CODE (y) == PLUS + && GET_MODE (y) == Pmode + && CONST_INT_P (XEXP (y, 1))) + { + offset = XEXP (y, 1); + y = XEXP (y, 0); + } if (GET_CODE (y) == UNSPEC && XINT (y, 1) == UNSPEC_TOCREL && ((GET_CODE (XEXP (x, 0)) == REG @@ -6396,6 +6405,8 @@ rs6000_delegitimize_address (rtx orig_x) XEXP (XEXP (XEXP (x, 0), 1), 0))))) { y = XVECEXP (y, 0, 0); + if (offset != NULL_RTX) + y = gen_rtx_PLUS (Pmode, y, offset); if (!MEM_P (orig_x)) return y; else @@ -6405,9 +6416,9 @@ rs6000_delegitimize_address (rtx orig_x) if (TARGET_MACHO && GET_CODE (orig_x) == LO_SUM - && GET_CODE (XEXP (x, 1)) == CONST) + && GET_CODE (XEXP (orig_x, 1)) == CONST) { - y = XEXP (XEXP (x, 1), 0); + y = XEXP (XEXP (orig_x, 1), 0); if (GET_CODE (y) == UNSPEC && XINT (y, 1) == UNSPEC_MACHOPIC_OFFSET) return XVECEXP (y, 0, 0);