From patchwork Fri Nov 9 09:17:27 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: 197997 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 913FD2C01C6 for ; Fri, 9 Nov 2012 20:17:55 +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=1353057475; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: 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=DxncpKd6msXJq88faDRI FNDL+h8=; b=JRAhXw4H0VsrdFAaeyuPtGclAT/m7gBv5pzWv+Mt0t/KYpFlT3XQ s0W5D/PS026xgmn845nCvfWh4KbvYgnYUZ/Iev25JLNHUsnVSzp1HzJIx2DXOlM6 cl1Ln3H8Qq4wK35or1gtNDs4oX9oW6/DRKF3Qdfxbim7YYi1ho42ntg= 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:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yJrHVxlL8uDcoFZI9O5VtRxz5RYfqRsN+f3fTCuh6vEZ6VThzBjWmZihkEjPMW 9bwdxs/H8DxeTmZ+hEcwMosrylK6MS7zO1ocKq2sOiJy1VIqVnrLC5MWRx/a7AKp LYaYZcTwuMX44KDBz5f+YrxuyXBXCRQIOYBNzLrpPZCLo=; Received: (qmail 28453 invoked by alias); 9 Nov 2012 09:17:47 -0000 Received: (qmail 28442 invoked by uid 22791); 9 Nov 2012 09:17:46 -0000 X-SWARE-Spam-Status: No, hits=-4.4 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_YE X-Spam-Check-By: sourceware.org Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Nov 2012 09:17:41 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa11so2524147pad.20 for ; Fri, 09 Nov 2012 01:17:40 -0800 (PST) Received: by 10.66.78.169 with SMTP id c9mr30138136pax.30.1352452660772; Fri, 09 Nov 2012 01:17:40 -0800 (PST) Received: from gnu-tools-1.localdomain ([180.159.182.187]) by mx.google.com with ESMTPS id t1sm17683014paw.11.2012.11.09.01.17.37 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Nov 2012 01:17:40 -0800 (PST) Received: by gnu-tools-1.localdomain (Postfix, from userid 1000) id D538D1A044F; Fri, 9 Nov 2012 01:17:27 -0800 (PST) Date: Fri, 9 Nov 2012 01:17:27 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: Patch: Print SImode register names to force addr32 prefix Message-ID: <20121109091727.GA23790@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi, Since x32 runs in 64-bit mode, for address -0x40000300(%rax), hardware sign-extends displacement from 32-bits to 64-bits and adds it to %rax. But x32 wants 32-bit -0x40000300, not 64-bit -0x40000300. This patch uses 32-bit registers instead of 64-bit registers when displacement < -16*1024*1024. -16*1024*1024 is used instead of 0 so that we will still generate -16(%rsp) instead of -16(%esp). Tested it on Linux/x32. OK to install? Thanks. H.J. --- 2012-11-09 H.J. Lu * config/i386/i386.c (ix86_print_operand_address): For x32, print SImode register names to force addr32 prefix if displacement < -16*1024*1024. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 78e840b..6d4fbb5 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -14502,6 +14514,17 @@ ix86_print_operand_address (FILE *file, rtx addr) gcc_assert (!code); code = 'l'; } + else if (code == 0 + && TARGET_X32 + && disp + && CONST_INT_P (disp) + && INTVAL (disp) < -16*1024*1024) + { + /* For x32, print SImode register names to force addr32 prefix + if displacement < -16*1024*1024 so that 32-bit displacement + isn't sign-extended to 64-bit. */ + code = 'k'; + } if (ASSEMBLER_DIALECT == ASM_ATT) {