From patchwork Fri Mar 2 20:56:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 144344 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 D6A9A1007D4 for ; Sat, 3 Mar 2012 07:56:42 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1331326604; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version: Content-Type:Content-Disposition:User-Agent:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=hEthX+Z4HFcdr19d/eu7JBdCW8U=; b=O5meUY6Td+DrzFTWuOA5Lb8h4t2kw7K5Yvogx+FmRY/aU78kZ7oclfWBY8g2K8 ylJGFtVR6mrZvAlo+7izF4vgoL80gFh5YamWdI6CMh1/mBVqBH3EZrbaih0Pw0HU 5xAmhm52bxC9NSSJrculSKKvUPwUaLvYDR3FeSn5DoUNM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-ExtLoop1:Received:Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Ded8azITe+6PxvR9IGxhdTAC/PcezE3wsgmwpuuRhJ9kCHx2/a5SVGHSYCRHgU 9qFVKI5pzViQeGJWXris8HR6FlgvBzgAwYHp7272WhPTx6+fC1+vD+MgOtSSOjpk ak9GKi9RGLNPvS0HY6QKLPAJONSRdjkkQJ2X3vKZraM/U=; Received: (qmail 28493 invoked by alias); 2 Mar 2012 20:56:39 -0000 Received: (qmail 28482 invoked by uid 22791); 2 Mar 2012 20:56:38 -0000 X-SWARE-Spam-Status: No, hits=-4.0 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 mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Mar 2012 20:56:04 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 02 Mar 2012 12:56:04 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by orsmga002.jf.intel.com with ESMTP; 02 Mar 2012 12:56:03 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id C1B79C186C; Fri, 2 Mar 2012 12:56:03 -0800 (PST) Date: Fri, 2 Mar 2012 12:56:03 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org, Uros Bizjak , Richard Henderson Subject: [PATCH 05/10] addr32: Load TP into register for TLS_MODEL_LOCAL_EXEC modes in x32 Message-ID: <20120302205603.GC2179@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, Since the 0x67 address prefix only zeros out the upper 32bits of the (reg) part in address fs:(reg), we can't use fs:(reg) as memory operand for x32 with Pmode == SImode. We have to load the address into a register first and use it as memory operand. Tested on Linux/x86-64. OK for trunk? Thanks. H.J. 2012-03-02 H.J. Lu * config/i386/i386.c (legitimize_tls_address): Load TP into register for TLS_MODEL_LOCAL_EXEC modes in x32. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7cb8fda..d6ec6ff 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -12687,7 +12687,16 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov) if (TARGET_64BIT || TARGET_ANY_GNU_TLS) { base = get_thread_pointer (for_mov || !TARGET_TLS_DIRECT_SEG_REFS); - return gen_rtx_PLUS (Pmode, base, off); + if (Pmode != word_mode) + { + /* Since address override works only on the (reg) part in + fs:(reg), we can't use it as memory operand. */ + rtx reg = gen_reg_rtx (Pmode); + emit_move_insn (reg, base); + return gen_rtx_PLUS (Pmode, reg, off); + } + else + return gen_rtx_PLUS (Pmode, base, off); } else {