From patchwork Mon Dec 24 15:40:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 208084 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 2E6A32C00A7 for ; Tue, 25 Dec 2012 02:40:49 +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=1356968450; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=YgWLpzx ZUpaMCEP3OUjw9NkMM34=; b=F526KDDO2EwkTP/bwMHEfQL4pOwbqSw00PR6V+l 8FRvorGsumstB84E7vV+XXNPBZpHBqfT5YQ6UPoiA2xuqzAl89LEKcoAG930GsAc E5dkE7xKv6gOicVgO0fmshpNltn2uf+8EcEBlPYeYRar3vU2yu5fp17pTGBFIB/0 hVXg= 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:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=TPbQgnEavETt19J1t3erIR7Pg0SPwKE8/gvprFvsUPb1JmEMr+WB7jtLzAfuLp BPgL/RfKkz74hAq5NplSvERs8SdJtNj4wtGU7pwzhKpgCdfk3JvG3jX4wwyd/RtL dQYJ/+6Rg8MeI+oLNc3WlatBWxbVXbuVANu+fWvfrmqPk=; Received: (qmail 16649 invoked by alias); 24 Dec 2012 15:40:40 -0000 Received: (qmail 16479 invoked by uid 22791); 24 Dec 2012 15:40:38 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, TW_HG, TW_PX, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-ob0-f174.google.com (HELO mail-ob0-f174.google.com) (209.85.214.174) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Dec 2012 15:40:31 +0000 Received: by mail-ob0-f174.google.com with SMTP id ta14so6784405obb.33 for ; Mon, 24 Dec 2012 07:40:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.95.133 with SMTP id dk5mr18616386obb.14.1356363628722; Mon, 24 Dec 2012 07:40:28 -0800 (PST) Received: by 10.182.153.201 with HTTP; Mon, 24 Dec 2012 07:40:28 -0800 (PST) Date: Mon, 24 Dec 2012 16:40:28 +0100 Message-ID: Subject: [RFC PATCH, i386]: Use %r15 for REAL_PIC_OFFSET_TABLE_REGNUM on x86_64 From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Richard Henderson , Jakub Jelinek , jh@suse.cz, "H.J. Lu" 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 Hello! Currently, we use %rbx as REAL_PIC_OFFSET_TABLE_REGNUM on x86_64. Since this register gets marked as fixed reg in ix86_conditional_register_usage, we get into troubles with insns that use %rbx (cmpxchg, cpuid). According to x86_64 psABI, we are free to use any register, so attached patch changes %rbx with %r15 (also following the example in the psABI). This patch has no implications on small code model (that doesn't use REAL_PIC_OFFSET_TABLE_REGNUM anyway), but on medium and large code model fixes usage of cpuid.h (please see PR 55712 [1]) and avoids a pair of xchgs around cmpxchg or cpuid instructions. Probably, we can also enhance ix86_select_alt_pic_regnum for x86_64, but this is 4.9 material. 2012-12-24 Uros Bizjak * config/i386/i386.md (R14_REG, R15_REG): New constants. * config/i386/i386.h (REAL_PIC_OFFSET_TABLE_REGNUM): Use R15_REG for 64bit targets. [1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55712 Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. Index: i386.h =================================================================== --- i386.h (revision 194703) +++ i386.h (working copy) @@ -1173,7 +1173,7 @@ the pic register when possible. The change is visible after the prologue has been emitted. */ -#define REAL_PIC_OFFSET_TABLE_REGNUM BX_REG +#define REAL_PIC_OFFSET_TABLE_REGNUM (TARGET_64BIT ? R15_REG : BX_REG) #define PIC_OFFSET_TABLE_REGNUM \ ((TARGET_64BIT && ix86_cmodel == CM_SMALL_PIC) \ Index: i386.md =================================================================== --- i386.md (revision 194703) +++ i386.md (working copy) @@ -301,6 +301,8 @@ (R11_REG 40) (R12_REG 41) (R13_REG 42) + (R14_REG 43) + (R15_REG 44) (XMM8_REG 45) (XMM9_REG 46) (XMM10_REG 47)