From patchwork Mon Oct 23 17:32:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116825 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4896504qgn; Mon, 23 Oct 2017 10:32:43 -0700 (PDT) X-Received: by 10.98.147.23 with SMTP id b23mr14063744pfe.5.1508779963792; Mon, 23 Oct 2017 10:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508779963; cv=none; d=google.com; s=arc-20160816; b=DXKUstOJbe1JVx+8bvBBYLHwj8eebkZ+UNZlO5Vx1QsmYxaKj0UCThPMpjheasfiVB or6zqp++7CG4mnrB7IJBAVTw1gIWAG4QAIC81Oq+HwNlgn+6h72ZGiFexlkHPbgYhOqp f+s7zIo05/skor0ssQjkS2SESeeI1XyIcconvM1aQdUM5sZSKveFYznCkPfEQyGAg48M 6XcaHGylW9ZfxuqAQz+zGBOHqH34Tyw8ZSIMci/V/E2K/my4nLlQBaM9ZnL67/f3woh1 udW6qYvcjBXPZJScJaAThEhYVmeWBufonLs6bqJYuDTn66Q7ddw9dwuBnN4zk0TZxz9r U5Tg== 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=L57gsF52h2LxhWkIXDiFoYtlH1fpcC49QRaHZ2rLDbQ=; b=nXlknXUZ1s4SloIS80Du34XYDtg+/0783I42+qJg7RI+LjHVDjgL1FOwumShQWUEtm 09UhQx/R9DxVqVLi4if9JqaOapu/ZWrQ+eIbuuDSNk+uqozWiZ6Yp8CqfZxSlH2ve4Jn Pmsoct4R+arianyPJUi3AbrcL9iGSRkNWek+VUNog88Z/TVsY5kv577ln1RDYQOlm/4L iOkrtvBuAtKfgmqYhsXc6b9ithI9ErRSsALZtAEBGJfKw9cFu3ph0L2ZFhnSSr8uX0MA x0PCIpEDdGn0ngQCppe6D8kTJBnMYOLS8QYRWR5pDaqB5nGKRewc8TbEzzO/50RT/NQb bvZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yAfmQ7li; spf=pass (google.com: domain of gcc-patches-return-464856-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464856-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 h1si4200506plk.624.2017.10.23.10.32.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464856-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=yAfmQ7li; spf=pass (google.com: domain of gcc-patches-return-464856-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464856-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=XYm+t1p7aP0R8r7xVQ06sIPjLkE00 sva1DRf2W6Wi6lt47UANrfqi0IFBg7UMqGDnRfZK0iCTDJYTZiwBSXdWWPgkMIvh ZF3BozT3GWUoTTsnDqbrSJ2eHEu1liOOENya/lU3cQ1RL0LdI4Jt1IuRraLSWQBn Y6c4eReNEuNTxY= 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=DEj7iaS50NItb/TMRfuT5JEstnE=; b=yAf mQ7liWMgKkFWJ/iGV5CArPGD9eoqDVOnrmEWnopdxbdHLkqe/f/9OmSuqhJ3Etwj fvloV41zI0ZQ4c7uPyaEhv0KXekz504fjo3pH86GhazyEfX5+OOmB5V7qHddwb+S VSNZcJL7Djui4C3YCFW2zBepwTdH6x5ZrVAmm5+0= Received: (qmail 45806 invoked by alias); 23 Oct 2017 17:32:29 -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 45786 invoked by uid 89); 23 Oct 2017 17:32:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:32:26 +0000 Received: by mail-wm0-f53.google.com with SMTP id t69so11009299wmt.2 for ; Mon, 23 Oct 2017 10:32:26 -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=L57gsF52h2LxhWkIXDiFoYtlH1fpcC49QRaHZ2rLDbQ=; b=A9Xb0WBhqR4CT6pP2WRrMtZBH/37UOsZwT+DM7SaAV/IJEmvUKgeWVpkB2y8cgj3f5 FoX3WnTRFOvQhQN0nFAXI+cZx+neN6cVPxH9YqHYgVRUwysp7BDyhRCyAAb70H4x1VyA SFMXHeR2xa0eDmcvzKr8ZwfCMKXpmfdyVuRG8tsoQGoKKpNNcWRH7HCXbswnJhOiRB4j o/S/Kohg9zAesNl/qhulya/FIuYc2pU6tzM0Ko2HYfDsVQUU1/juhPJHesjkDvwmLVE8 3GxzIdT6zmkSRslTNBwXL0tpp95NHckrayOfsa2TKEOY/pMsmhC8Ps7IUVYzdmBZwYKs SNzA== X-Gm-Message-State: AMCzsaUDzmsoL14ajU3dh8ykDA1lFmzGULvefzMogV2WcUtZboM8n21s cavrRLpDgJTGXGZlnYPHLrk4fV8neZs= X-Google-Smtp-Source: ABhQp+RRjzENTe7LD88nUPIJsZtizKkSjRlj/5JP8JULOpT46UaKuT/faEts0xrD5eP7dJW3BGQnvw== X-Received: by 10.28.69.91 with SMTP id s88mr5961933wma.19.1508779944453; Mon, 23 Oct 2017 10:32:24 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id q81sm6770986wmd.27.2017.10.23.10.32.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:32:23 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [080/nnn] poly_int: tree-vect-generic.c References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:32:22 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87a80hhis9.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes tree-vect-generic.c cope with variable-length vectors. Decomposition is only supported for constant-length vectors, since we should never generate unsupported variable-length operations. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-vect-generic.c (nunits_for_known_piecewise_op): New function. (expand_vector_piecewise): Use it instead of TYPE_VECTOR_SUBPARTS. (expand_vector_addition, add_rshift, expand_vector_divmod): Likewise. (expand_vector_condition, vector_element): Likewise. (subparts_gt): New function. (get_compute_type): Use subparts_gt. (count_type_subparts): Delete. (expand_vector_operations_1): Use subparts_gt instead of count_type_subparts. Index: gcc/tree-vect-generic.c =================================================================== --- gcc/tree-vect-generic.c 2017-10-23 17:11:39.944370794 +0100 +++ gcc/tree-vect-generic.c 2017-10-23 17:22:45.856865193 +0100 @@ -41,6 +41,26 @@ Free Software Foundation; either version static void expand_vector_operations_1 (gimple_stmt_iterator *); +/* Return the number of elements in a vector type TYPE that we have + already decided needs to be expanded piecewise. We don't support + this kind of expansion for variable-length vectors, since we should + always check for target support before introducing uses of those. */ +static unsigned int +nunits_for_known_piecewise_op (const_tree type) +{ + return TYPE_VECTOR_SUBPARTS (type); +} + +/* Return true if TYPE1 has more elements than TYPE2, where either + type may be a vector or a scalar. */ + +static inline bool +subparts_gt (tree type1, tree type2) +{ + poly_uint64 n1 = VECTOR_TYPE_P (type1) ? TYPE_VECTOR_SUBPARTS (type1) : 1; + poly_uint64 n2 = VECTOR_TYPE_P (type2) ? TYPE_VECTOR_SUBPARTS (type2) : 1; + return must_gt (n1, n2); +} /* Build a constant of type TYPE, made of VALUE's bits replicated every TYPE_SIZE (INNER_TYPE) bits to fit TYPE's precision. */ @@ -254,7 +274,7 @@ expand_vector_piecewise (gimple_stmt_ite vec *v; tree part_width = TYPE_SIZE (inner_type); tree index = bitsize_int (0); - int nunits = TYPE_VECTOR_SUBPARTS (type); + int nunits = nunits_for_known_piecewise_op (type); int delta = tree_to_uhwi (part_width) / tree_to_uhwi (TYPE_SIZE (TREE_TYPE (type))); int i; @@ -338,7 +358,7 @@ expand_vector_addition (gimple_stmt_iter if (INTEGRAL_TYPE_P (TREE_TYPE (type)) && parts_per_word >= 4 - && TYPE_VECTOR_SUBPARTS (type) >= 4) + && nunits_for_known_piecewise_op (type) >= 4) return expand_vector_parallel (gsi, f_parallel, type, a, b, code); else @@ -373,7 +393,7 @@ expand_vector_comparison (gimple_stmt_it add_rshift (gimple_stmt_iterator *gsi, tree type, tree op0, int *shiftcnts) { optab op; - unsigned int i, nunits = TYPE_VECTOR_SUBPARTS (type); + unsigned int i, nunits = nunits_for_known_piecewise_op (type); bool scalar_shift = true; for (i = 1; i < nunits; i++) @@ -418,7 +438,7 @@ expand_vector_divmod (gimple_stmt_iterat bool has_vector_shift = true; int mode = -1, this_mode; int pre_shift = -1, post_shift; - unsigned int nunits = TYPE_VECTOR_SUBPARTS (type); + unsigned int nunits = nunits_for_known_piecewise_op (type); int *shifts = XALLOCAVEC (int, nunits * 4); int *pre_shifts = shifts + nunits; int *post_shifts = pre_shifts + nunits; @@ -867,7 +887,6 @@ expand_vector_condition (gimple_stmt_ite tree index = bitsize_int (0); tree comp_width = width; tree comp_index = index; - int nunits = TYPE_VECTOR_SUBPARTS (type); int i; location_t loc = gimple_location (gsi_stmt (*gsi)); @@ -920,6 +939,7 @@ expand_vector_condition (gimple_stmt_ite warning_at (loc, OPT_Wvector_operation_performance, "vector condition will be expanded piecewise"); + int nunits = nunits_for_known_piecewise_op (type); vec_alloc (v, nunits); for (i = 0; i < nunits; i++) { @@ -1189,7 +1209,7 @@ vector_element (gimple_stmt_iterator *gs vect_type = TREE_TYPE (vect); vect_elt_type = TREE_TYPE (vect_type); - elements = TYPE_VECTOR_SUBPARTS (vect_type); + elements = nunits_for_known_piecewise_op (vect_type); if (TREE_CODE (idx) == INTEGER_CST) { @@ -1446,8 +1466,7 @@ get_compute_type (enum tree_code code, o tree vector_compute_type = type_for_widest_vector_mode (TREE_TYPE (type), op); if (vector_compute_type != NULL_TREE - && (TYPE_VECTOR_SUBPARTS (vector_compute_type) - < TYPE_VECTOR_SUBPARTS (compute_type)) + && subparts_gt (compute_type, vector_compute_type) && TYPE_VECTOR_SUBPARTS (vector_compute_type) > 1 && (optab_handler (op, TYPE_MODE (vector_compute_type)) != CODE_FOR_nothing)) @@ -1476,15 +1495,6 @@ get_compute_type (enum tree_code code, o return compute_type; } -/* Helper function of expand_vector_operations_1. Return number of - vector elements for vector types or 1 for other types. */ - -static inline int -count_type_subparts (tree type) -{ - return VECTOR_TYPE_P (type) ? TYPE_VECTOR_SUBPARTS (type) : 1; -} - static tree do_cond (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b, tree bitpos, tree bitsize, enum tree_code code, @@ -1704,8 +1714,7 @@ expand_vector_operations_1 (gimple_stmt_ /* The rtl expander will expand vector/scalar as vector/vector if necessary. Pick one with wider vector type. */ tree compute_vtype = get_compute_type (code, opv, type); - if (count_type_subparts (compute_vtype) - > count_type_subparts (compute_type)) + if (subparts_gt (compute_vtype, compute_type)) { compute_type = compute_vtype; op = opv; @@ -1735,14 +1744,12 @@ expand_vector_operations_1 (gimple_stmt_ tree compute_rtype = get_compute_type (RSHIFT_EXPR, opr, type); /* The rtl expander will expand vector/scalar as vector/vector if necessary. Pick one with wider vector type. */ - if (count_type_subparts (compute_lvtype) - > count_type_subparts (compute_ltype)) + if (subparts_gt (compute_lvtype, compute_ltype)) { compute_ltype = compute_lvtype; opl = oplv; } - if (count_type_subparts (compute_rvtype) - > count_type_subparts (compute_rtype)) + if (subparts_gt (compute_rvtype, compute_rtype)) { compute_rtype = compute_rvtype; opr = oprv; @@ -1750,11 +1757,9 @@ expand_vector_operations_1 (gimple_stmt_ /* Pick the narrowest type from LSHIFT_EXPR, RSHIFT_EXPR and BIT_IOR_EXPR. */ compute_type = compute_ltype; - if (count_type_subparts (compute_type) - > count_type_subparts (compute_rtype)) + if (subparts_gt (compute_type, compute_rtype)) compute_type = compute_rtype; - if (count_type_subparts (compute_type) - > count_type_subparts (compute_otype)) + if (subparts_gt (compute_type, compute_otype)) compute_type = compute_otype; /* Verify all 3 operations can be performed in that type. */ if (compute_type != TREE_TYPE (type))