From patchwork Thu Dec 28 20:53:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 122878 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3906272qgn; Thu, 28 Dec 2017 12:53:21 -0800 (PST) X-Google-Smtp-Source: ACJfBovF9D1MijF1V5koNH5+lFfmk2+IaFJqhNCgZ4b4jlUeZNguzo7T57xRAqcj/aOPgAn7oMrx X-Received: by 10.99.164.73 with SMTP id c9mr5054363pgp.435.1514494401461; Thu, 28 Dec 2017 12:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514494401; cv=none; d=google.com; s=arc-20160816; b=rmUsxz1oExvMlHbuzSElgrySO0pl+6MG6DuawP60rryZvCRDZGPHmCAbKnmbJcD7I0 ZX5wOniY3Vo5zqOohPFb7LnbpTA+Y81yWCTLSIMQC4p1BsHYAAUu/njXefoVgp27FuIh yh+nowz07PycEo6szpqJzkypHGHnsapO+zUO7hPr//Ugs8ujNUFMgXL1VyHJh8h95TxK kC30dDixn5SXcCrhnZ2WKU2H70rHoL6cxk5TCHfj1XJ3fFXuVvfA7kDyB2e3ffC1S1sp ZH3rqetzGJWjFBIMEe5xJPlQh0cIM7PhB2L0Kw23gdPKwS0T1Za+4QOrqajr1AAoAkkT FBkg== 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=2GshoXJZWKvXdI4w6vgC97d9vO3baYlEsO82HzNtawk=; b=gEW0TV4lgdNqGQqpMQg9EF2Qm3IlYpO4bT0pAB/gJTpAGg6FRMBP247A5UOl/ZmWuU gne2tiVRIzzRhoObLVE61fbtaBeVSw1Xffn08030BqOEX7og0JBI1Dh6fl3pgsM+Rqi0 TdlBA++qFknrHwrbEpUXcJLe+wavlRySj/vASuwAzb9e+HFQWaA4BKXpV5Qb6IysMdkQ TQupN5bDY8OudG2Q3SOJXg69z3Gfi6kib+40SwQqTGE+Ra7BqSVJTa8yod9JfMemEWE9 Q5grg+SI1NwyNVEfKgv3kbqGSZJqAKxokYrk5Kh8qOSppAqe75F1g948+dDEZ9DFMDLj ozQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OjFTwamg; spf=pass (google.com: domain of gcc-patches-return-469873-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-469873-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 a5si25210786plh.263.2017.12.28.12.53.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Dec 2017 12:53:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-469873-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=OjFTwamg; spf=pass (google.com: domain of gcc-patches-return-469873-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-469873-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=mqE9YXjXY/4JZGZ+fAyfzV+C/zv8P fHQCNkMa8qfcp8qSmlY9R5AscGFTYCgL/KJBIJzPiAOlb/1RdQU6cRz9hhxq4Spt 9t55GNFNqCZfa+R7i0swiC811NyK83TB+o4/JsLAWjqi7CGlX0c8ZVFZlY7nL/r9 Nitinykm1HhMFg= 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=/d8h4RGP215XTo2E2jjNWa3pYd4=; b=OjF TwamgzxcKIaC368leXCgUluFfrA+hGPYauXgz7P3WZ6D5G6Btpraok9uupcsMmnE cpSj4qvMWSAKNml8QPLLiaHOS274sN9d+hQNq3XNrO9P4jg25j6SuSsYUDaryIpm AfOJLGqUI3ss851MCdnDllUjTO3eTUkMwCTykEoM= Received: (qmail 47448 invoked by alias); 28 Dec 2017 20:53:09 -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 47429 invoked by uid 89); 28 Dec 2017 20:53:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, 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; Thu, 28 Dec 2017 20:53:06 +0000 Received: by mail-wr0-f174.google.com with SMTP id p69so31334626wrb.8 for ; Thu, 28 Dec 2017 12:53:06 -0800 (PST) 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=2GshoXJZWKvXdI4w6vgC97d9vO3baYlEsO82HzNtawk=; b=N1qPmNzWLbdAY40JvK/tkXxe+tZGGCgv9mhNmMntUQkVIH6IBvBaGGd+3Op50rCC0y FNMIVxtFrXrS7uiy1AXe5AjZC6LtPPsbjc4ujOZwCxlpHfXUoH7DVsFBcIWkBR/mYZ6z m4uKgyK+XrqJpZ1CqLx4NHelX265ORsRVmSPb398MD2DTna0m9DSwklpdFGsqRWbshKR fnwTg9oNPGMEglhIdIwyPoIfjtWwEjMcMqfSlQMOkBmxpWHeCwiAJ6G9MOR+U3JhIFjK kI65ohm63qE9bEke0CTL2lC0n3R2TV+jXf0fvnDFO45/Tnl80gZSMTMjxLGG1mnDTxfO LZmQ== X-Gm-Message-State: AKGB3mIpytchAF3UX+RlPJf2ygY31jUEcR4u0Xmeim6gX0XVPafJVXRI EGDcwtn/TMFwpT0DQThW3RZcGggHDro= X-Received: by 10.223.161.81 with SMTP id r17mr32016129wrr.230.1514494384381; Thu, 28 Dec 2017 12:53:04 -0800 (PST) Received: from localhost ([95.145.138.186]) by smtp.gmail.com with ESMTPSA id i17sm23336576wrf.71.2017.12.28.12.53.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Dec 2017 12:53:03 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [3/4] Make more use of rtx_vector_builder References: <874loainn7.fsf@linaro.org> Date: Thu, 28 Dec 2017 20:53:03 +0000 In-Reply-To: <874loainn7.fsf@linaro.org> (Richard Sandiford's message of "Thu, 28 Dec 2017 20:49:16 +0000") Message-ID: <87o9mih8wg.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch makes various bits of CONST_VECTOR-building code use rtx_vector_builder, operating directly on a specific encoding. 2017-12-28 Richard Sandiford gcc/ * expr.c: Include rtx-vector-builder.h. (const_vector_mask_from_tree): Use rtx_vector_builder and operate directly on the tree encoding. (const_vector_from_tree): Likewise. * optabs.c: Include rtx-vector-builder.h. (expand_vec_perm_var): Use rtx_vector_builder and create a repeating sequence of "u" values. * vec-perm-indices.c: Include rtx-vector-builder.h. (vec_perm_indices_to_rtx): Use rtx_vector_builder and operate directly on the vec_perm_indices encoding. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-12-22 12:58:44.518127920 +0000 +++ gcc/expr.c 2017-12-22 13:09:48.535709302 +0000 @@ -61,6 +61,7 @@ Software Foundation; either version 3, o #include "tree-chkp.h" #include "rtl-chkp.h" #include "ccmp.h" +#include "rtx-vector-builder.h" /* If this is nonzero, we do not bother generating VOLATILE @@ -11761,32 +11762,25 @@ try_tablejump (tree index_type, tree ind static rtx const_vector_mask_from_tree (tree exp) { - rtvec v; - unsigned i, units; - tree elt; - machine_mode inner, mode; - - mode = TYPE_MODE (TREE_TYPE (exp)); - units = VECTOR_CST_NELTS (exp); - inner = GET_MODE_INNER (mode); - - v = rtvec_alloc (units); + machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); + machine_mode inner = GET_MODE_INNER (mode); - for (i = 0; i < units; ++i) + rtx_vector_builder builder (mode, VECTOR_CST_NPATTERNS (exp), + VECTOR_CST_NELTS_PER_PATTERN (exp)); + unsigned int count = builder.encoded_nelts (); + for (unsigned int i = 0; i < count; ++i) { - elt = VECTOR_CST_ELT (exp, i); - + tree elt = VECTOR_CST_ELT (exp, i); gcc_assert (TREE_CODE (elt) == INTEGER_CST); if (integer_zerop (elt)) - RTVEC_ELT (v, i) = CONST0_RTX (inner); + builder.quick_push (CONST0_RTX (inner)); else if (integer_onep (elt) || integer_minus_onep (elt)) - RTVEC_ELT (v, i) = CONSTM1_RTX (inner); + builder.quick_push (CONSTM1_RTX (inner)); else gcc_unreachable (); } - - return gen_rtx_CONST_VECTOR (mode, v); + return builder.build (); } /* EXP is a VECTOR_CST in which each element is either all-zeros or all-ones. @@ -11816,12 +11810,7 @@ const_scalar_mask_from_tree (scalar_int_ static rtx const_vector_from_tree (tree exp) { - rtvec v; - unsigned i, units; - tree elt; - machine_mode inner, mode; - - mode = TYPE_MODE (TREE_TYPE (exp)); + machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); if (initializer_zerop (exp)) return CONST0_RTX (mode); @@ -11829,27 +11818,25 @@ const_vector_from_tree (tree exp) if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp))) return const_vector_mask_from_tree (exp); - units = VECTOR_CST_NELTS (exp); - inner = GET_MODE_INNER (mode); - - v = rtvec_alloc (units); + machine_mode inner = GET_MODE_INNER (mode); - for (i = 0; i < units; ++i) + rtx_vector_builder builder (mode, VECTOR_CST_NPATTERNS (exp), + VECTOR_CST_NELTS_PER_PATTERN (exp)); + unsigned int count = builder.encoded_nelts (); + for (unsigned int i = 0; i < count; ++i) { - elt = VECTOR_CST_ELT (exp, i); - + tree elt = VECTOR_CST_ELT (exp, i); if (TREE_CODE (elt) == REAL_CST) - RTVEC_ELT (v, i) = const_double_from_real_value (TREE_REAL_CST (elt), - inner); + builder.quick_push (const_double_from_real_value (TREE_REAL_CST (elt), + inner)); else if (TREE_CODE (elt) == FIXED_CST) - RTVEC_ELT (v, i) = CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (elt), - inner); + builder.quick_push (CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (elt), + inner)); else - RTVEC_ELT (v, i) = immed_wide_int_const (wi::to_poly_wide (elt), - inner); + builder.quick_push (immed_wide_int_const (wi::to_poly_wide (elt), + inner)); } - - return gen_rtx_CONST_VECTOR (mode, v); + return builder.build (); } /* Build a decl for a personality function given a language prefix. */ Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-12-22 13:06:03.092620276 +0000 +++ gcc/optabs.c 2017-12-22 13:09:48.535709302 +0000 @@ -33,6 +33,7 @@ Software Foundation; either version 3, o #include "emit-rtl.h" #include "recog.h" #include "diagnostic-core.h" +#include "rtx-vector-builder.h" /* Include insn-config.h before expr.h so that HAVE_conditional_move is properly defined. */ @@ -5609,7 +5610,6 @@ expand_vec_perm_var (machine_mode mode, enum insn_code icode; unsigned int i, w, u; rtx tmp, sel_qi; - rtvec vec; w = GET_MODE_SIZE (mode); u = GET_MODE_UNIT_SIZE (mode); @@ -5661,10 +5661,10 @@ expand_vec_perm_var (machine_mode mode, /* Add the byte offset to each byte element. */ /* Note that the definition of the indicies here is memory ordering, so there should be no difference between big and little endian. */ - vec = rtvec_alloc (w); - for (i = 0; i < w; ++i) - RTVEC_ELT (vec, i) = GEN_INT (i % u); - tmp = gen_rtx_CONST_VECTOR (qimode, vec); + rtx_vector_builder byte_indices (qimode, u, 1); + for (i = 0; i < u; ++i) + byte_indices.quick_push (GEN_INT (i)); + tmp = byte_indices.build (); sel_qi = expand_simple_binop (qimode, PLUS, sel, tmp, sel, 0, OPTAB_DIRECT); gcc_assert (sel_qi != NULL); Index: gcc/vec-perm-indices.c =================================================================== --- gcc/vec-perm-indices.c 2017-12-22 13:05:20.155253154 +0000 +++ gcc/vec-perm-indices.c 2017-12-22 13:09:48.535709302 +0000 @@ -29,6 +29,7 @@ Software Foundation; either version 3, o #include "memmodel.h" #include "emit-rtl.h" #include "selftest.h" +#include "rtx-vector-builder.h" /* Switch to a new permutation vector that selects between NINPUTS vector inputs that have NELTS_PER_INPUT elements each. Take the elements of the @@ -223,11 +224,12 @@ vec_perm_indices_to_rtx (machine_mode mo { gcc_assert (GET_MODE_CLASS (mode) == MODE_VECTOR_INT && GET_MODE_NUNITS (mode) == indices.length ()); - unsigned int nelts = indices.length (); - rtvec v = rtvec_alloc (nelts); - for (unsigned int i = 0; i < nelts; ++i) - RTVEC_ELT (v, i) = gen_int_mode (indices[i], GET_MODE_INNER (mode)); - return gen_rtx_CONST_VECTOR (mode, v); + rtx_vector_builder sel (mode, indices.encoding ().npatterns (), + indices.encoding ().nelts_per_pattern ()); + unsigned int encoded_nelts = sel.encoded_nelts (); + for (unsigned int i = 0; i < encoded_nelts; i++) + sel.quick_push (gen_int_mode (indices[i], GET_MODE_INNER (mode))); + return sel.build (); } #if CHECKING_P