From patchwork Mon Oct 23 11:24:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116699 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4529579qgn; Mon, 23 Oct 2017 04:24:51 -0700 (PDT) X-Received: by 10.98.86.81 with SMTP id k78mr12767843pfb.58.1508757891425; Mon, 23 Oct 2017 04:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508757891; cv=none; d=google.com; s=arc-20160816; b=OtgTIS4i2pc+xulyeV4yBYrjGa9NjOlrYhupRqTc2zXMGMn8iNFxOmKCHrSF8H1q6b 4ECb8fue3rKoaoZgeQ24hOZ8kDyvuopM2HKGQ0GgxJGoAf1oxwxqmD0/M+wBCfc9ch9j o5b1ethwogNsWYN7DZABWsAbZKK/LgtRMZof7/ldBc+dshy4E0ARTpQeSXhQwCsthydi yoyA55qB4aZpboVLjhUNLCk4Ku3wB24ZzsTZw4Lb1gq0zwth6N1S9Q6sqMpygRk4PECs eb6KNx/rMEApUICtquiaFDIbug76LfONVjhFHudKdUPb5ESQ4ceQOfUI5Oq3MkBQ1ymS IbEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=owprC9C2Xj2lG4dNXUThlEUV6T/1GkGmemTHSkQHgpQ=; b=HP7gxnSX785PiecT//TSclwteziMOB2Le7IAkS63ClyKmcDDs5kMSPAaakieNdQEIy q5M6xyqqUOH5TUiewTHmBN+yQvNhaJZ7DOxyBtG7SE6Iv19Aw5cs9H4MTBdXmeoyZa8N Q8x+8aCxc7s9Kj+2mX5F8zNmY7MTTkrPgU7S8T1Zw1WqPV8e/4sJWc8d+B1QCUxaN31G I9xkLEGjxnViX/ZSdlJLUhLFa0PD7K2G/E7dPNuP+RhG9rh+Ajo+GSDes6O8Qp1rYWFZ BFC/+cX2qlD68vYENXjyGBUeLQJJgnL5FwGuEZEJONOw13J2Up0NynA/AIAh5CG7+Phv esEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DLXFTlLv; spf=pass (google.com: domain of gcc-patches-return-464739-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464739-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n10si1736230plp.150.2017.10.23.04.24.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 04:24:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464739-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DLXFTlLv; spf=pass (google.com: domain of gcc-patches-return-464739-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464739-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=N+YSU1xKOgdTciBhi7/jmxSWYVv8W irB7qkDZIGMabzJx07wmUgUgDBkRfSv1Xk83/MdDMnOEswvSn4O5Xrf1oTNU5LlS 0RZ499xfPWLJTm0eG53fttvOPI326TUYXjZHsHq58Iqtqp4TnPUm1sS/Z7dM8dwQ 7xoWSP/a824o6o= 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=RqgKKp+PoN9L91XUKd0P1HnUjac=; b=DLX FTlLv/onDsLNaFtUlUP6y3bnq+BOamxBbwc/o7ZqQlsn30JTFU7+ICAL/9+W8AWj fv7nk0FFMh3Un78yNVoqDUHDz7btZRvLdaQluivGjdBRe++9ZVpNziVhuJ6G47Nv HUFFLLmOqDrhzTJTOn3jpiYQ2Ag1UpSiKybj+7zk= Received: (qmail 64368 invoked by alias); 23 Oct 2017 11:24:33 -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 64318 invoked by uid 89); 23 Oct 2017 11:24:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2835 X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 11:24:31 +0000 Received: by mail-wm0-f51.google.com with SMTP id m72so8197610wmc.0 for ; Mon, 23 Oct 2017 04:24:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=owprC9C2Xj2lG4dNXUThlEUV6T/1GkGmemTHSkQHgpQ=; b=baE0NmQeHez5G80WYOiSTRK6JX+piUAiKZ9i6Ts19GK6lD4UoJBLm/AyjL182MFhmT 3TB3idzK2Y4Pjft4K20Qb2iYkO6gUdk+rUW8sKk4Bxq4ON6jyPWlbEyp3icboZh+MXVu JM2gg3zs2r9wshGMpCeny264zi+e5RTV2SEfs2yEkN3keEcbcksI5DqSqsYgBgYdQ3Vn LRRsPPu4cQ6QEaZvgg/rJzTf1ENkt69fS5zUiJU9RMkQdD6KBgVZXSctR+2mcx06JIF8 SSA6FOvXw3lOx3DioNHbMEVxQeUq12UwFMuVcFB3L5laWOKl0jhGmmTQ6HC8p34X54Sv +Ydg== X-Gm-Message-State: AMCzsaXFSMCkVXhWfynsoWcSiKBiBoNbWaX7iDSxtcMIXrou4s9qDwp5 CPz5mXeVNY4mlhpCqOBr7Trp47DldoY= X-Google-Smtp-Source: ABhQp+QLkmzG0FQFWtJMMT7CnGpbj2xSpXlkS53sghObAmXJjyMSgw/FBVkdcYV269zItOPnTK6PZw== X-Received: by 10.28.93.200 with SMTP id r191mr5525309wmb.19.1508757869391; Mon, 23 Oct 2017 04:24:29 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id h8sm4303073wme.30.2017.10.23.04.24.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 04:24:28 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [12/nn] Add an is_narrower_int_mode helper function References: <87wp3mxgir.fsf@linaro.org> Date: Mon, 23 Oct 2017 12:24:27 +0100 In-Reply-To: <87wp3mxgir.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 12:14:36 +0100") Message-ID: <87h8uqw1hw.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a function for testing whether an arbitrary mode X is an integer mode that is narrower than integer mode Y. This is useful for code like expand_float and expand_fix that could in principle handle vectors as well as scalars. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (is_narrower_int_mode): New function * optabs.c (expand_float, expand_fix): Use it. * dwarf2out.c (rotate_loc_descriptor): Likewise. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-10-23 11:44:06.561720156 +0100 +++ gcc/machmode.h 2017-10-23 11:44:23.979432614 +0100 @@ -893,6 +893,17 @@ is_complex_float_mode (machine_mode mode return false; } +/* Return true if MODE is a scalar integer mode with a precision + smaller than LIMIT's precision. */ + +inline bool +is_narrower_int_mode (machine_mode mode, scalar_int_mode limit) +{ + scalar_int_mode int_mode; + return (is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (limit)); +} + namespace mode_iterator { /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */ Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-10-23 11:44:07.732431531 +0100 +++ gcc/optabs.c 2017-10-23 11:44:23.980398548 +0100 @@ -4820,7 +4820,7 @@ expand_float (rtx to, rtx from, int unsi rtx value; convert_optab tab = unsignedp ? ufloat_optab : sfloat_optab; - if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_PRECISION (SImode)) + if (is_narrower_int_mode (GET_MODE (from), SImode)) from = convert_to_mode (SImode, from, unsignedp); libfunc = convert_optab_libfunc (tab, GET_MODE (to), GET_MODE (from)); @@ -5002,7 +5002,7 @@ expand_fix (rtx to, rtx from, int unsign that the mode of TO is at least as wide as SImode, since those are the only library calls we know about. */ - if (GET_MODE_PRECISION (GET_MODE (to)) < GET_MODE_PRECISION (SImode)) + if (is_narrower_int_mode (GET_MODE (to), SImode)) { target = gen_reg_rtx (SImode); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-10-23 11:44:05.684652559 +0100 +++ gcc/dwarf2out.c 2017-10-23 11:44:23.979432614 +0100 @@ -14530,8 +14530,7 @@ rotate_loc_descriptor (rtx rtl, scalar_i dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL }; int i; - if (GET_MODE (rtlop1) != VOIDmode - && GET_MODE_BITSIZE (GET_MODE (rtlop1)) < GET_MODE_BITSIZE (mode)) + if (is_narrower_int_mode (GET_MODE (rtlop1), mode)) rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1); op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, VAR_INIT_STATUS_INITIALIZED);