From patchwork Tue May 21 09:26:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 245233 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4BA292C00A4 for ; Tue, 21 May 2013 19:27:19 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=TE5TpAlxCv8ZWsmg iCaIBBMKIq+1tfWNOMoQsa1NDh1OUFnxF0RtMeUAYyfJXSLvHU2YdoeNT8OqfaxQ 2zFGQD3bX0U9wL5DUnM8aW/U7iBF7rXNnPa4I/+SYRzZQqVNkqaBLXS8zJ29DyCe cuR46sEKXDtJimag3kBHXt3GzAs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=izaBo5ONziPP0Ic0R1zkwe fDvC8=; b=w6yM4RnSdQ5yg0TQDHnItTyTJAkfpzveSgVZprZrTsdycVouW3J3Gb mN0ro44q84TEvMxSvYcZYZ/UKR0lgCfxt2BHiP+8MK4sEsUZ7lv0DnFA9ueI1ePu dfvL5zHk/iG8P92kbjb/5ruZmQTyahP/tEYbDfloO8mKjYyE+8otU= Received: (qmail 30425 invoked by alias); 21 May 2013 09:27:12 -0000 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 Received: (qmail 30412 invoked by uid 89); 21 May 2013 09:27:12 -0000 X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, TW_XF autolearn=ham version=3.3.1 Received: from e06smtp10.uk.ibm.com (HELO e06smtp10.uk.ibm.com) (195.75.94.106) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 21 May 2013 09:26:39 +0000 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 May 2013 10:24:37 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 21 May 2013 10:24:36 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3BDA817D805D for ; Tue, 21 May 2013 10:27:46 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4L9QPEN28901612 for ; Tue, 21 May 2013 09:26:25 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r4L9QZqa005267 for ; Tue, 21 May 2013 03:26:35 -0600 Received: from sandifor-thinkpad.stglab.manchester.uk.ibm.com (sandifor-laptop.stglab.manchester.uk.ibm.com [9.174.185.182]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r4L9QYhc005242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 21 May 2013 03:26:35 -0600 From: Richard Sandiford To: Andreas Krebbel Mail-Followup-To: Andreas Krebbel , gcc-patches@gcc.gnu.org, rsandifo@linux.vnet.ibm.com Cc: gcc-patches@gcc.gnu.org Subject: Re: RFA: Use gen_int_mode in plus_constant References: <87wqrk5aoa.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com> <519B2444.6020709@linux.vnet.ibm.com> <87zjvosp5j.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com> <519B3AA3.9060207@linux.vnet.ibm.com> Date: Tue, 21 May 2013 10:26:33 +0100 In-Reply-To: <519B3AA3.9060207@linux.vnet.ibm.com> (Andreas Krebbel's message of "Tue, 21 May 2013 11:13:07 +0200") Message-ID: <87mwrosmye.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13052109-4966-0000-0000-000005CC74C3 Andreas Krebbel writes: > On 21/05/13 10:39, Richard Sandiford wrote: >> Andreas Krebbel writes: >>> On 30/04/13 16:56, Richard Sandiford wrote: >>>> This patch fixes out the GEN_INT/gen_int_mode that Richard pointed out >>>> in the wide-int review. It also passes "mode" rather than "VOIDmode" >>>> to immed_double_int_const. (As discussed in that thread, the latter >>>> change shouldn't make any difference in practice, but is still more >>>> correct in principle.) >>>> >>>> Bootstrapped & regression-tested on x86_64-linux-gnu. OK to install? >>>> >>>> Richard >>>> >>>> gcc/ >>>> * explow.c (plus_constant): Pass "mode" to immed_double_int_const. >>>> Use gen_int_mode rather than GEN_INT. >>>> >>>> Index: gcc/explow.c >>>> =================================================================== >>>> --- gcc/explow.c 2013-02-25 09:41:58.000000000 +0000 >>>> +++ gcc/explow.c 2013-04-30 15:52:57.270362112 +0100 >>>> @@ -106,10 +106,10 @@ plus_constant (enum machine_mode mode, r >>>> if (overflow) >>>> gcc_unreachable (); >>>> >>>> - return immed_double_int_const (v, VOIDmode); >>>> + return immed_double_int_const (v, mode); >>>> } >>>> >>>> - return GEN_INT (INTVAL (x) + c); >>>> + return gen_int_mode (INTVAL (x) + c, mode); >>> >>> This calls trunc_int_for_mode which fails for mode == VOIDmode. >>> On s390x gcc.c-torture/compile/20021008-1.c fails due to this. >> >> But it's invalid to pass mode == VOIDmode to plus_constant too. >> Which caller is causing trouble? >> >> Thanks, >> Richard >> > > Hi Richard, > > the call comes from reload when checking a const_int memory address. Ah, thanks. Could you give the patch below a go? Richard gcc/ * recog.c (offsettable_address_addr_space_p): Fix calculation of address mode. Move pointer mode initialization to the same place. Index: gcc/recog.c =================================================================== --- gcc/recog.c 2013-04-29 12:38:00.000000000 +0100 +++ gcc/recog.c 2013-05-21 10:21:24.553671961 +0100 @@ -1953,9 +1953,6 @@ offsettable_address_addr_space_p (int st (strictp ? strict_memory_address_addr_space_p : memory_address_addr_space_p); unsigned int mode_sz = GET_MODE_SIZE (mode); -#ifdef POINTERS_EXTEND_UNSIGNED - enum machine_mode pointer_mode = targetm.addr_space.pointer_mode (as); -#endif if (CONSTANT_ADDRESS_P (y)) return 1; @@ -1966,6 +1963,13 @@ offsettable_address_addr_space_p (int st if (mode_dependent_address_p (y, as)) return 0; + enum machine_mode address_mode = GET_MODE (y); + if (address_mode == VOIDmode) + address_mode = targetm.addr_space.address_mode (as); +#ifdef POINTERS_EXTEND_UNSIGNED + enum machine_mode pointer_mode = targetm.addr_space.pointer_mode (as); +#endif + /* ??? How much offset does an offsettable BLKmode reference need? Clearly that depends on the situation in which it's being used. However, the current situation in which we test 0xffffffff is @@ -1981,7 +1985,7 @@ offsettable_address_addr_space_p (int st int good; y1 = *y2; - *y2 = plus_constant (GET_MODE (y), *y2, mode_sz - 1); + *y2 = plus_constant (address_mode, *y2, mode_sz - 1); /* Use QImode because an odd displacement may be automatically invalid for any wider mode. But it should be valid for a single byte. */ good = (*addressp) (QImode, y, as); @@ -2002,20 +2006,20 @@ offsettable_address_addr_space_p (int st if (GET_CODE (y) == LO_SUM && mode != BLKmode && mode_sz <= GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT) - z = gen_rtx_LO_SUM (GET_MODE (y), XEXP (y, 0), - plus_constant (GET_MODE (y), XEXP (y, 1), + z = gen_rtx_LO_SUM (address_mode, XEXP (y, 0), + plus_constant (address_mode, XEXP (y, 1), mode_sz - 1)); #ifdef POINTERS_EXTEND_UNSIGNED /* Likewise for a ZERO_EXTEND from pointer_mode. */ else if (POINTERS_EXTEND_UNSIGNED > 0 && GET_CODE (y) == ZERO_EXTEND && GET_MODE (XEXP (y, 0)) == pointer_mode) - z = gen_rtx_ZERO_EXTEND (GET_MODE (y), + z = gen_rtx_ZERO_EXTEND (address_mode, plus_constant (pointer_mode, XEXP (y, 0), mode_sz - 1)); #endif else - z = plus_constant (GET_MODE (y), y, mode_sz - 1); + z = plus_constant (address_mode, y, mode_sz - 1); /* Use QImode because an odd displacement may be automatically invalid for any wider mode. But it should be valid for a single byte. */