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: 804946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460787-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PiBCxkDD"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xckq46mtBz9s83 for ; Wed, 23 Aug 2017 20:55:28 +1000 (AEST) 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=Gezy/cS7ZcVcFbA5De5L42CRX2Iqe1nWx1IoqDnvY9V3qetJao3kO TIO3A9WpG3sa8w+81V5sabJaCfuJSdvznJs1+VNleE82/pyowylekpGmvsljlSEj ZvJt+LDXN767Qjvrdckv9omvh3hWdlZwfik/1Mk1/Hc0u/SE6y1Vd0= 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=PiBCxkDDZpeh125kF/au RnoV59hvbc5E4X0+S2HOYyTXl25KrU9doyiPf6Vs83nkmmFsIvD8+BWCp0JMVO5x vUt5lBHByzhmDdz+XULxHmI7JTUnY5rsw95KMvBLlQiMvYLomJqo3U82TIAdAHdl EsBxqEyjnBURwzMsBhbCx5c= 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);