From patchwork Wed Aug 23 10:55:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 110734 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3944870qge; Wed, 23 Aug 2017 03:55:35 -0700 (PDT) X-Received: by 10.99.95.150 with SMTP id t144mr2293236pgb.349.1503485735003; Wed, 23 Aug 2017 03:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503485734; cv=none; d=google.com; s=arc-20160816; b=gMvHxr6O94rL9c0HXpMA+RqVDzQL1FM70E88MfEmsvN5zIO/78W50Up+EJ20fGJ16v WtKnZ+l7av69oSS65wS/i+2AmEP7S7jq/YFObrnzsl+qlzJQSGLIaaUqB84X6mOpKlUE ttIKsdr9q4hnXpqOe6hJcbFHgoX5d3bZP1adQY73kDuRR15so8atMISDSmv5tHl0WtW3 ys+3kbdDplky/mV58VJqZ7hN+pbMXOLpTKh3yP5RjF887MzwEdlB1D2mW06I8LfF9sXc Fm7M+WHSIGVnROOS/hXvzLrJtv1jEDvxnYIVk2lDeKRIrMyVzvuje1C9F+JBjvUwsAS6 TbJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date: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=E7M3LirGfo9A7mvP2CAuLLIlEhRqrzoBnfAwAqexZCc=; b=pPSksQHiNUKzXhlmNzTMlUGd8tm0CtAbdYr0Uyvaihh1LUkJi1gXfl7e3vH/jHWIoz gFvddh+y8QHQgjN9p49mMmz/wq2oNoYOrZU30SGnKiwzxg86KPYhOXGGeHoKQyZMoHp9 4C/cOmXzOpGQrhqy/YSbsnAQSMSVbKO5tEczw29NVPQ/pMpx4woNcxmFnUUABLixYlPj rlF/FEZprNB24IUlJbikykB8T97POTV2Cs9BGmhqCXlRd5Rl2dl9qUCk5vYXOaNZHKm4 DjycFlOYg9aMeVkxrUUka/+KWh99zbIWQfU2KWBnjr3JmNrc7Gm1BbAJwn+Tbm2FwKVv SOiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MXMCj8+k; spf=pass (google.com: domain of gcc-patches-return-460787-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460787-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 m1si862394pgm.489.2017.08.23.03.55.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 03:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-460787-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=MXMCj8+k; spf=pass (google.com: domain of gcc-patches-return-460787-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460787-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:date:message-id:mime-version:content-type; q=dns; s= default; b=AoF/UGIk7dS1piMl7sV/ryIQDfg+XBi5+OiEOQFuCUkYl99bIJUNF Xy7nYTJOFeORSHEUyMd7rS8uMYuAkoODs3/VP0q/S2zvhhE3Upqmo45B0s6UbGrf A67U7Hm0YD6zsojsxHv8d60qQ9eJvgQ4dS+zEVYQXMpgpTVLxh1UsU= 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:date:message-id:mime-version:content-type; s= default; bh=oqoJNEBclIbiBHIlbqDDtyr0Gjs=; b=MXMCj8+kbFSgrGuVB8J0 FTvdZ2B8nZrCC6OfTJD/ZlDN9+vbNgwxcakU305CKmNCEOODkSv8P8KUfqTaCf1E SN5725X2ICOcodYacXw6VCMLiolWJfOnvjNjfhTgJKWZRHBBYOC92tSZI8DxqgM5 cbtJhg/1gQ4/T1NJU4m8c3Y= Received: (qmail 86545 invoked by alias); 23 Aug 2017 10:55:18 -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 85229 invoked by uid 89); 23 Aug 2017 10:55:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 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= X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Aug 2017 10:55:14 +0000 Received: by mail-wr0-f174.google.com with SMTP id a47so4371059wra.0 for ; Wed, 23 Aug 2017 03:55:14 -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:date:message-id :user-agent:mime-version; bh=E7M3LirGfo9A7mvP2CAuLLIlEhRqrzoBnfAwAqexZCc=; b=EQmLm+/PnugJ6k81qIsjaQXR3drDn7nrV8DjfRpQYbcmTyC08+AOJFOgdQyROoGQHC Xx1OVOxlSXc0GNYUd8MEIvWsqB5gfEmzmwl8SIWhCzMkVGVDY79C7XakRu2eRCZf/i2y o/n0GhpMRTL3iI7U0kzkXU4FwzvEHG4kuiqR2YvX6OCZ59GBiz8u5LcBDqHQytoBbRSX nSMx4VjH5atBgxIW/BU+VmmAIoNvLorDw3VdQYZsP23POU7nNepdSSowk7VtvGIadDwg AMfTIm2bxrlh9GIpRy6yX7he3d+GG5sO5svkOoN7RBSEfIn1dhwzolg9bgBXh4Mk+spX IXlQ== X-Gm-Message-State: AHYfb5jtgGoSTfOPZSdkQa7C2PsVTEHgZX2p254U1Khn45V9+HfbqjTL OZETNP19kXR3YtLcmxfjYg== X-Received: by 10.223.150.139 with SMTP id u11mr1353852wrb.259.1503485712497; Wed, 23 Aug 2017 03:55:12 -0700 (PDT) Received: from localhost (92.40.249.210.threembb.co.uk. [92.40.249.210]) by smtp.gmail.com with ESMTPSA id 63sm2100564wra.30.2017.08.23.03.55.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2017 03:55:11 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Make more use of GET_MODE_UNIT_SIZE Date: Wed, 23 Aug 2017 11:55:10 +0100 Message-ID: <87o9r6tuy9.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses GET_MODE_UNIT_SIZE instead of GET_MODE_SIZE in cases where, for compound modes, the mode of the scalar elements is what matters. E.g. the choice between truncation and extension is really based on the modes of the consistuent scalars rather than the mode as a whole. None of the existing code was wrong. The patch simply makes things easier when converting to variable-sized modes. Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by making sure that there were no differences in testsuite assembly output for one target per CPU. OK to install? Richard 2017-08-22 Richard Sandiford Alan Hayward David Sherwood gcc/ * optabs.c (add_equal_note): Use GET_MODE_UNIT_SIZE. (widened_mode): Likewise. (expand_unop): Likewise. * ree.c (transform_ifelse): Likewise. (merge_def_and_ext): Likewise. (combine_reaching_defs): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-08-03 10:40:53.028490556 +0100 +++ gcc/optabs.c 2017-08-23 10:47:48.126586565 +0100 @@ -138,8 +138,8 @@ add_equal_note (rtx_insn *insns, rtx tar if (GET_MODE (op0) != VOIDmode && GET_MODE (target) != GET_MODE (op0)) { note = gen_rtx_fmt_e (code, GET_MODE (op0), copy_rtx (op0)); - if (GET_MODE_SIZE (GET_MODE (op0)) - > GET_MODE_SIZE (GET_MODE (target))) + if (GET_MODE_UNIT_SIZE (GET_MODE (op0)) + > GET_MODE_UNIT_SIZE (GET_MODE (target))) note = simplify_gen_unary (TRUNCATE, GET_MODE (target), note, GET_MODE (op0)); else @@ -173,12 +173,12 @@ widened_mode (machine_mode to_mode, rtx if (m0 == VOIDmode && m1 == VOIDmode) return to_mode; - else if (m0 == VOIDmode || GET_MODE_SIZE (m0) < GET_MODE_SIZE (m1)) + else if (m0 == VOIDmode || GET_MODE_UNIT_SIZE (m0) < GET_MODE_UNIT_SIZE (m1)) result = m1; else result = m0; - if (GET_MODE_SIZE (result) > GET_MODE_SIZE (to_mode)) + if (GET_MODE_UNIT_SIZE (result) > GET_MODE_UNIT_SIZE (to_mode)) return to_mode; return result; @@ -2982,9 +2982,9 @@ expand_unop (machine_mode mode, optab un else { eq_value = gen_rtx_fmt_e (optab_to_code (unoptab), mode, op0); - if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode)) + if (GET_MODE_UNIT_SIZE (outmode) < GET_MODE_UNIT_SIZE (mode)) eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode); - else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode)) + else if (GET_MODE_UNIT_SIZE (outmode) > GET_MODE_UNIT_SIZE (mode)) eq_value = simplify_gen_unary (ZERO_EXTEND, outmode, eq_value, mode); } Index: gcc/ree.c =================================================================== --- gcc/ree.c 2017-08-23 10:44:17.185477350 +0100 +++ gcc/ree.c 2017-08-23 10:47:48.126586565 +0100 @@ -427,7 +427,8 @@ transform_ifelse (ext_cand *cand, rtx_in srcreg2 = XEXP (SET_SRC (set_insn), 2); /* If the conditional move already has the right or wider mode, there is nothing to do. */ - if (GET_MODE_SIZE (GET_MODE (dstreg)) >= GET_MODE_SIZE (cand->mode)) + if (GET_MODE_UNIT_SIZE (GET_MODE (dstreg)) + >= GET_MODE_UNIT_SIZE (cand->mode)) return true; map_srcreg = gen_rtx_REG (cand->mode, REGNO (srcreg)); @@ -717,8 +718,8 @@ merge_def_and_ext (ext_cand *cand, rtx_i && state->modified[INSN_UID (def_insn)].mode == ext_src_mode))) { - if (GET_MODE_SIZE (GET_MODE (SET_DEST (*sub_rtx))) - >= GET_MODE_SIZE (cand->mode)) + if (GET_MODE_UNIT_SIZE (GET_MODE (SET_DEST (*sub_rtx))) + >= GET_MODE_UNIT_SIZE (cand->mode)) return true; /* If def_insn is already scheduled to be deleted, don't attempt to modify it. */ @@ -926,7 +927,8 @@ combine_reaching_defs (ext_cand *cand, c || (set = single_set (cand->insn)) == NULL_RTX) return false; mode = GET_MODE (SET_DEST (set)); - gcc_assert (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (cand->mode)); + gcc_assert (GET_MODE_UNIT_SIZE (mode) + >= GET_MODE_UNIT_SIZE (cand->mode)); cand->mode = mode; } Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-08-23 10:44:17.187477282 +0100 +++ gcc/simplify-rtx.c 2017-08-23 10:47:48.127582392 +0100 @@ -1266,10 +1266,9 @@ simplify_unary_operation_1 (enum rtx_cod if ((GET_CODE (op) == FLOAT_TRUNCATE && flag_unsafe_math_optimizations) || GET_CODE (op) == FLOAT_EXTEND) - return simplify_gen_unary (GET_MODE_SIZE (GET_MODE (XEXP (op, - 0))) - > GET_MODE_SIZE (mode) - ? FLOAT_TRUNCATE : FLOAT_EXTEND, + return simplify_gen_unary (GET_MODE_UNIT_SIZE (GET_MODE (XEXP (op, 0))) + > GET_MODE_UNIT_SIZE (mode) + ? FLOAT_TRUNCATE : FLOAT_EXTEND, mode, XEXP (op, 0), mode);