From patchwork Wed Dec 6 15:22:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 120867 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7187260qgn; Wed, 6 Dec 2017 07:22:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMarwVrQ8y+5h7Z4pSssf4xMBF/wipkBinSUT+S3XMBJuuBv5Dj1d0XnbZXyMLAHM8QTM6zV X-Received: by 10.84.237.2 with SMTP id s2mr1407757plk.415.1512573779787; Wed, 06 Dec 2017 07:22:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512573779; cv=none; d=google.com; s=arc-20160816; b=sNcGd+G619m+K1P58HplEGAGoB544Ckw92Z4cFf50CRbNRS0qbsPgkfGsR+A/W8esT gUP7473i2CzPSDAdaU0TuBSmhVvMJccNpr8bkOYAhGBVYyHJjROtJuODVAWz1KCr6Yqa +oawVESynigVRi4jGlVacBSvHZtHIIPQGsH8+Af12R1pHKId7/R3JgJ0mG3aEJ/lcyWW ZCXjbNDnSBM8SibcIQo3npDdheI6pirRpEq9lEPxB59evLbhB5au2kZLvlm+3S+AULKo v9UjBird6gFq4bywkpmrGKF+3x6pBXEJbvi/iX4m6zmYjLN9/fw/rP7W9ko60MOtBgS/ 2RLw== 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:cc: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=fJBJj5D4YwF3HI1uNmBHITKKuZCciscfcgptXNinuJI=; b=XWBZ1arz9nmQ9iWQY6Z/SzkTj24+uuj1smzeAm68qeyW1Pdm3OyrJxazD79M2g6gJA +7FqzJ1XPRI8d/tTzS4KHY7ef7VV1Wxc0SH11NiQesdtnYK3TCq/gP5wgv/GUa4ysCbz cSQW45waOOOLeIiDjCIZPzWs76BrrI5+fM9il1UBcT5384Xo1H8mq1kYceMtl5WBjJFg YOKQb2o+mHSe5pXoB9Iedtov0DZgPDpf8SAJ7IbclrL1JB2ZI/1mPfRXsrrDEvPzmdwT zq2O6JeE3GJnYrGn6TsGJClJw7rpl1hmMAbiu2Itc8fYXGbmgkBDckkIHLP+8E4+AIdY R5Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Ot55htgc; spf=pass (google.com: domain of gcc-patches-return-468613-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-468613-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 c1si2197260pld.12.2017.12.06.07.22.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 07:22:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-468613-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=Ot55htgc; spf=pass (google.com: domain of gcc-patches-return-468613-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-468613-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:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=HY/TLvXqmzFn7tom oxZsokJONGkCf/kdv/yqXGlD3r3gAtgu6jSrj6sbelD/MvzS8zpe63upZJQpWLH4 Du01lszA7J5D9nBPWrMT+VFP0Y1q0YNp/7xw1Tk7PJPLrKCewNGYbem2wD4wuWFR 64N9Se6ocKNNuk3tuwLXiaMWHSo= 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:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=wsd8whfJFC5qEIsip/yqUS LQH+U=; b=Ot55htgcgwYaE1p4/YlcFDBov7KmDbkM+I0OYOUNUzG+x3/4Xw6XVg rDTE5Kp7mRUgj10Yy9gnqLL1ewvoWsbmX9q6cQbAyntYzWbtkEbd1hFCZFAsgBoR CgrESbUeDCY2Nd71I5zvZtpTpRmJgPI2IDhKZJivZSANFFzHFWXsA= Received: (qmail 122384 invoked by alias); 6 Dec 2017 15:22:47 -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 122361 invoked by uid 89); 6 Dec 2017 15:22:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=PLUS X-HELO: mail-wr0-f169.google.com Received: from mail-wr0-f169.google.com (HELO mail-wr0-f169.google.com) (209.85.128.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Dec 2017 15:22:42 +0000 Received: by mail-wr0-f169.google.com with SMTP id k61so4296910wrc.4 for ; Wed, 06 Dec 2017 07:22:42 -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:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version; bh=fJBJj5D4YwF3HI1uNmBHITKKuZCciscfcgptXNinuJI=; b=f52Wd4hirpaHck3lPVDR5ukRaI/MC5buQ+Mtut/QwDi6Z6v0t2G5ujKQZa8+U2IS6h 26+ipq/3mKVyOeClaK1sbya+yLsFeQoUnE8XKVlQ5YBgpmwmcXyEC5mW0920IpzGyrtU o6GNkpdZ8xl8DXwzEiGENcG9YIqSqtrKTiq+XaB+RIVfvr1Dvpyakqphfq7nXt925iy0 vTVJEmaBElQzy9cXPvMzeKDbSg+xcCUU7bWLd5vQduvWzsZCA6LXeGku+P3vTqcNhEs/ zn9zj/JudAPjkes09uCxryIDkxVRd8wbW9VgdwtoxGOBbzWgXuX9gNyU7a1EgB76ACgj uDoQ== X-Gm-Message-State: AJaThX7Kst8DPw2A6HmcWsFqMnRK26XhACx1OIc1/RREFvrswHjas2nV gyn/0hzjLcZ2BQbnq1PWVHmtRcjBcc8= X-Received: by 10.223.184.173 with SMTP id i42mr21330746wrf.31.1512573760120; Wed, 06 Dec 2017 07:22:40 -0800 (PST) Received: from localhost (188.29.165.206.threembb.co.uk. [188.29.165.206]) by smtp.gmail.com with ESMTPSA id c12sm3279840wmi.43.2017.12.06.07.22.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Dec 2017 07:22:39 -0800 (PST) From: Richard Sandiford To: Richard Biener Mail-Followup-To: Richard Biener , GCC Patches , richard.sandiford@linaro.org Cc: GCC Patches Subject: Use tree_vector_builder instead of build_vector References: <87shcxl2ka.fsf@linaro.org> <87efohkohu.fsf@linaro.org> <87efof9a6h.fsf@linaro.org> <87fu8nao27.fsf@linaro.org> Date: Wed, 06 Dec 2017 15:22:36 +0000 In-Reply-To: <87fu8nao27.fsf@linaro.org> (Richard Sandiford's message of "Wed, 06 Dec 2017 15:11:44 +0000") Message-ID: <87a7yvank3.fsf_-_@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch switches most build_vector calls over to tree_vector_builder, using explicit encodings where appropriate. Later patches handle the remaining uses of build_vector. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also spot-checked on sparc64-linux-gnu. OK to install? Thanks, Richard 2017-12-06 Richard Sandiford gcc/ * config/sparc/sparc.c: Include tree-vector-builder.h. (sparc_fold_builtin): Use tree_vector_builder instead of build_vector. * expmed.c: Include tree-vector-builder.h. (make_tree): Use tree_vector_builder instead of build_vector. * fold-const.c: Include tree-vector-builder.h. (const_binop): Use tree_vector_builder instead of build_vector. (const_unop): Likewise. (native_interpret_vector): Likewise. (fold_vec_perm): Likewise. (fold_ternary_loc): Likewise. * gimple-fold.c: Include tree-vector-builder.h. (gimple_fold_stmt_to_constant_1): Use tree_vector_builder instead of build_vector. * tree-ssa-forwprop.c: Include tree-vector-builder.h. (simplify_vector_constructor): Use tree_vector_builder instead of build_vector. * tree-vect-generic.c: Include tree-vector-builder.h. (add_rshift): Use tree_vector_builder instead of build_vector. (expand_vector_divmod): Likewise. (optimize_vector_constructor): Likewise. * tree-vect-loop.c: Include tree-vector-builder.h. (vect_create_epilog_for_reduction): Use tree_vector_builder instead of build_vector. Explicitly use a stepped encoding for { 1, 2, 3, ... }. * tree-vect-slp.c: Include tree-vector-builder.h. (vect_get_constant_vectors): Use tree_vector_builder instead of build_vector. (vect_transform_slp_perm_load): Likewise. (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c: Include tree-vector-builder.h. (vectorizable_bswap): Use tree_vector_builder instead of build_vector. (vect_gen_perm_mask_any): Likewise. (vectorizable_call): Likewise. Explicitly use a stepped encoding. * tree.c: (build_vector_from_ctor): Use tree_vector_builder instead of build_vector. (build_vector_from_val): Likewise. Explicitly use a duplicate encoding. Index: gcc/config/sparc/sparc.c =================================================================== --- gcc/config/sparc/sparc.c 2017-12-05 14:24:52.587013199 +0000 +++ gcc/config/sparc/sparc.c 2017-12-06 14:48:52.885162299 +0000 @@ -57,6 +57,7 @@ the Free Software Foundation; either ver #include "tree-pass.h" #include "context.h" #include "builtins.h" +#include "tree-vector-builder.h" /* This file should be included last. */ #include "target-def.h" @@ -11752,14 +11753,14 @@ sparc_fold_builtin (tree fndecl, int n_a tree inner_type = TREE_TYPE (rtype); unsigned i; - auto_vec n_elts (VECTOR_CST_NELTS (arg0)); + tree_vector_builder n_elts (rtype, VECTOR_CST_NELTS (arg0), 1); for (i = 0; i < VECTOR_CST_NELTS (arg0); ++i) { unsigned HOST_WIDE_INT val = TREE_INT_CST_LOW (VECTOR_CST_ELT (arg0, i)); n_elts.quick_push (build_int_cst (inner_type, val << 4)); } - return build_vector (rtype, n_elts); + return n_elts.build (); } break; @@ -11774,9 +11775,9 @@ sparc_fold_builtin (tree fndecl, int n_a if (TREE_CODE (arg0) == VECTOR_CST && TREE_CODE (arg1) == VECTOR_CST) { tree inner_type = TREE_TYPE (rtype); - auto_vec n_elts (VECTOR_CST_NELTS (arg0)); + tree_vector_builder n_elts (rtype, VECTOR_CST_NELTS (arg0), 1); sparc_handle_vis_mul8x16 (&n_elts, code, inner_type, arg0, arg1); - return build_vector (rtype, n_elts); + return n_elts.build (); } break; @@ -11788,7 +11789,7 @@ sparc_fold_builtin (tree fndecl, int n_a if (TREE_CODE (arg0) == VECTOR_CST && TREE_CODE (arg1) == VECTOR_CST) { - auto_vec n_elts (2 * VECTOR_CST_NELTS (arg0)); + tree_vector_builder n_elts (rtype, 2 * VECTOR_CST_NELTS (arg0), 1); unsigned i; for (i = 0; i < VECTOR_CST_NELTS (arg0); ++i) { @@ -11796,7 +11797,7 @@ sparc_fold_builtin (tree fndecl, int n_a n_elts.quick_push (VECTOR_CST_ELT (arg1, i)); } - return build_vector (rtype, n_elts); + return n_elts.build (); } break; Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-11-29 11:06:34.698180685 +0000 +++ gcc/expmed.c 2017-12-06 14:48:52.886162258 +0000 @@ -40,6 +40,7 @@ Software Foundation; either version 3, o #include "explow.h" #include "expr.h" #include "langhooks.h" +#include "tree-vector-builder.h" struct target_expmed default_target_expmed; #if SWITCHABLE_TARGET @@ -5184,14 +5185,14 @@ make_tree (tree type, rtx x) int i; /* Build a tree with vector elements. */ - auto_vec elts (units); + tree_vector_builder elts (type, units, 1); for (i = 0; i < units; ++i) { rtx elt = CONST_VECTOR_ELT (x, i); elts.quick_push (make_tree (itype, elt)); } - return build_vector (type, elts); + return elts.build (); } case PLUS: Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-12-06 14:46:14.129599986 +0000 +++ gcc/fold-const.c 2017-12-06 14:48:52.887162217 +0000 @@ -81,6 +81,7 @@ Software Foundation; either version 3, o #include "selftest.h" #include "stringpool.h" #include "attribs.h" +#include "tree-vector-builder.h" /* Nonzero if we are folding constants inside an initializer; zero otherwise. */ @@ -1507,7 +1508,7 @@ const_binop (enum tree_code code, tree t gcc_assert (in_nelts == VECTOR_CST_NELTS (arg2) && out_nelts == TYPE_VECTOR_SUBPARTS (type)); - auto_vec elts (out_nelts); + tree_vector_builder elts (type, out_nelts, 1); for (i = 0; i < out_nelts; i++) { tree elt = (i < in_nelts @@ -1521,7 +1522,7 @@ const_binop (enum tree_code code, tree t elts.quick_push (elt); } - return build_vector (type, elts); + return elts.build (); } case VEC_WIDEN_MULT_LO_EXPR: @@ -1548,7 +1549,7 @@ const_binop (enum tree_code code, tree t else /* if (code == VEC_WIDEN_MULT_ODD_EXPR) */ scale = 1, ofs = 1; - auto_vec elts (out_nelts); + tree_vector_builder elts (type, out_nelts, 1); for (out = 0; out < out_nelts; out++) { unsigned int in = (out << scale) + ofs; @@ -1565,7 +1566,7 @@ const_binop (enum tree_code code, tree t elts.quick_push (elt); } - return build_vector (type, elts); + return elts.build (); } default:; @@ -1704,7 +1705,7 @@ const_unop (enum tree_code code, tree ty else subcode = FLOAT_EXPR; - auto_vec elts (out_nelts); + tree_vector_builder elts (type, out_nelts, 1); for (i = 0; i < out_nelts; i++) { tree elt = fold_convert_const (subcode, TREE_TYPE (type), @@ -1714,7 +1715,7 @@ const_unop (enum tree_code code, tree ty elts.quick_push (elt); } - return build_vector (type, elts); + return elts.build (); } default: @@ -7377,7 +7378,7 @@ native_interpret_vector (tree type, cons if (size * count > len) return NULL_TREE; - auto_vec elements (count); + tree_vector_builder elements (type, count, 1); for (i = 0; i < count; ++i) { elem = native_interpret_expr (etype, ptr+(i*size), size); @@ -7385,7 +7386,7 @@ native_interpret_vector (tree type, cons return NULL_TREE; elements.quick_push (elem); } - return build_vector (type, elements); + return elements.build (); } @@ -8755,7 +8756,7 @@ fold_vec_perm (tree type, tree arg0, tre || !vec_cst_ctor_to_array (arg1, nelts, in_elts + nelts)) return NULL_TREE; - auto_vec out_elts (nelts); + tree_vector_builder out_elts (type, nelts, 1); for (i = 0; i < nelts; i++) { if (!CONSTANT_CLASS_P (in_elts[sel[i]])) @@ -8772,7 +8773,7 @@ fold_vec_perm (tree type, tree arg0, tre return build_constructor (type, v); } else - return build_vector (type, out_elts); + return out_elts.build (); } /* Try to fold a pointer difference of type TYPE two address expressions of @@ -11426,10 +11427,10 @@ fold_ternary_loc (location_t loc, enum t if (n == 1) return VECTOR_CST_ELT (arg0, idx); - auto_vec vals (n); + tree_vector_builder vals (type, n, 1); for (unsigned i = 0; i < n; ++i) vals.quick_push (VECTOR_CST_ELT (arg0, idx + i)); - return build_vector (type, vals); + return vals.build (); } } } @@ -11565,10 +11566,10 @@ fold_ternary_loc (location_t loc, enum t if (need_mask_canon && arg2 == op2) { tree eltype = TREE_TYPE (TREE_TYPE (arg2)); - auto_vec tsel (nelts); + tree_vector_builder tsel (TREE_TYPE (arg2), nelts, 1); for (i = 0; i < nelts; i++) tsel.quick_push (build_int_cst (eltype, sel[i])); - op2 = build_vector (TREE_TYPE (arg2), tsel); + op2 = tsel.build (); changed = true; } @@ -11608,11 +11609,11 @@ fold_ternary_loc (location_t loc, enum t else { unsigned int nelts = VECTOR_CST_NELTS (arg0); - auto_vec elts (nelts); + tree_vector_builder elts (type, nelts, 1); elts.quick_grow (nelts); - for (unsigned int i = 0; i < VECTOR_CST_NELTS (arg0); ++i) + for (unsigned int i = 0; i < nelts; ++i) elts[i] = (i == k ? arg1 : VECTOR_CST_ELT (arg0, i)); - return build_vector (type, elts); + return elts.build (); } } } Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c 2017-12-05 14:24:56.014949665 +0000 +++ gcc/gimple-fold.c 2017-12-06 14:48:52.888162175 +0000 @@ -63,6 +63,7 @@ Free Software Foundation; either version #include "diagnostic-core.h" #include "intl.h" #include "calls.h" +#include "tree-vector-builder.h" /* Return true when DECL can be referenced from current unit. FROM_DECL (if non-null) specify constructor of variable DECL was taken from. @@ -6022,7 +6023,7 @@ gimple_fold_stmt_to_constant_1 (gimple * tree val; nelts = TYPE_VECTOR_SUBPARTS (TREE_TYPE (rhs)); - auto_vec vec (nelts); + tree_vector_builder vec (TREE_TYPE (rhs), nelts, 1); FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), i, val) { val = (*valueize) (val); @@ -6034,7 +6035,7 @@ gimple_fold_stmt_to_constant_1 (gimple * return NULL_TREE; } - return build_vector (TREE_TYPE (rhs), vec); + return vec.build (); } if (subcode == OBJ_TYPE_REF) { Index: gcc/tree-ssa-forwprop.c =================================================================== --- gcc/tree-ssa-forwprop.c 2017-11-29 11:06:31.942215941 +0000 +++ gcc/tree-ssa-forwprop.c 2017-12-06 14:48:52.888162175 +0000 @@ -46,6 +46,7 @@ the Free Software Foundation; either ver #include "tree-cfgcleanup.h" #include "cfganal.h" #include "optabs-tree.h" +#include "tree-vector-builder.h" /* This pass propagates the RHS of assignment statements into use sites of the LHS of the assignment. It's basically a specialized @@ -2116,10 +2117,10 @@ simplify_vector_constructor (gimple_stmt || GET_MODE_SIZE (TYPE_MODE (mask_type)) != GET_MODE_SIZE (TYPE_MODE (type))) return false; - auto_vec mask_elts (nelts); + tree_vector_builder mask_elts (mask_type, nelts, 1); for (i = 0; i < nelts; i++) mask_elts.quick_push (build_int_cst (TREE_TYPE (mask_type), sel[i])); - op2 = build_vector (mask_type, mask_elts); + op2 = mask_elts.build (); if (conv_code == ERROR_MARK) gimple_assign_set_rhs_with_ops (gsi, VEC_PERM_EXPR, orig, orig, op2); else Index: gcc/tree-vect-generic.c =================================================================== --- gcc/tree-vect-generic.c 2017-11-29 11:06:34.810688336 +0000 +++ gcc/tree-vect-generic.c 2017-12-06 14:48:52.889162134 +0000 @@ -37,6 +37,7 @@ Free Software Foundation; either version #include "gimplify-me.h" #include "gimplify.h" #include "tree-cfg.h" +#include "tree-vector-builder.h" static void expand_vector_operations_1 (gimple_stmt_iterator *); @@ -398,11 +399,10 @@ add_rshift (gimple_stmt_iterator *gsi, t if (op != unknown_optab && optab_handler (op, TYPE_MODE (type)) != CODE_FOR_nothing) { - auto_vec vec (nunits); + tree_vector_builder vec (type, nunits, 1); for (i = 0; i < nunits; i++) vec.quick_push (build_int_cst (TREE_TYPE (type), shiftcnts[i])); - return gimplify_build2 (gsi, RSHIFT_EXPR, type, op0, - build_vector (type, vec)); + return gimplify_build2 (gsi, RSHIFT_EXPR, type, op0, vec.build ()); } return NULL_TREE; @@ -635,12 +635,12 @@ expand_vector_divmod (gimple_stmt_iterat mask_type = build_same_sized_truth_vector_type (type); zero = build_zero_cst (type); cond = build2 (LT_EXPR, mask_type, op0, zero); - auto_vec vec (nunits); + tree_vector_builder vec (type, nunits, 1); for (i = 0; i < nunits; i++) vec.quick_push (build_int_cst (TREE_TYPE (type), (HOST_WIDE_INT_1U << shifts[i]) - 1)); - cst = build_vector (type, vec); + cst = vec.build (); addend = make_ssa_name (type); stmt = gimple_build_assign (addend, VEC_COND_EXPR, cond, cst, zero); @@ -674,12 +674,12 @@ expand_vector_divmod (gimple_stmt_iterat else { tree mask; - auto_vec vec (nunits); + tree_vector_builder vec (type, nunits, 1); for (i = 0; i < nunits; i++) vec.quick_push (build_int_cst (TREE_TYPE (type), (HOST_WIDE_INT_1U << shifts[i]) - 1)); - mask = build_vector (type, vec); + mask = vec.build (); op = optab_for_tree_code (BIT_AND_EXPR, type, optab_default); if (op != unknown_optab && optab_handler (op, TYPE_MODE (type)) != CODE_FOR_nothing) @@ -753,10 +753,10 @@ expand_vector_divmod (gimple_stmt_iterat return NULL_TREE; } - auto_vec vec (nunits); + tree_vector_builder vec (type, nunits, 1); for (i = 0; i < nunits; i++) vec.quick_push (build_int_cst (TREE_TYPE (type), mulc[i])); - mulcst = build_vector (type, vec); + mulcst = vec.build (); cur_op = gimplify_build2 (gsi, MULT_HIGHPART_EXPR, type, cur_op, mulcst); @@ -1104,7 +1104,7 @@ optimize_vector_constructor (gimple_stmt } if (all_same) return; - auto_vec cst (nelts); + tree_vector_builder cst (type, nelts, 1); for (i = 0; i < nelts; i++) { tree this_base = CONSTRUCTOR_ELT (rhs, i)->value; @@ -1127,7 +1127,7 @@ optimize_vector_constructor (gimple_stmt g = gimple_build_assign (make_ssa_name (type), rhs); gsi_insert_before (gsi, g, GSI_SAME_STMT); g = gimple_build_assign (lhs, PLUS_EXPR, gimple_assign_lhs (g), - build_vector (type, cst)); + cst.build ()); gsi_replace (gsi, g, false); } Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-11-29 11:06:34.910905236 +0000 +++ gcc/tree-vect-loop.c 2017-12-06 14:48:52.889162134 +0000 @@ -51,6 +51,7 @@ Software Foundation; either version 3, o #include "tree-cfg.h" #include "tree-if-conv.h" #include "internal-fn.h" +#include "tree-vector-builder.h" /* Loop Vectorization Pass. @@ -4497,10 +4498,10 @@ vect_create_epilog_for_reduction (vec vtemp (nunits_out); - for (k = 0; k < nunits_out; ++k) + tree_vector_builder vtemp (cr_index_vector_type, 1, 3); + for (k = 0; k < 3; ++k) vtemp.quick_push (build_int_cst (cr_index_scalar_type, k + 1)); - tree series_vect = build_vector (cr_index_vector_type, vtemp); + tree series_vect = vtemp.build (); /* Create a vector of the step value. */ tree step = build_int_cst (cr_index_scalar_type, nunits_out); Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2017-12-05 14:24:56.178946625 +0000 +++ gcc/tree-vect-slp.c 2017-12-06 14:48:52.890162093 +0000 @@ -41,6 +41,7 @@ Software Foundation; either version 3, o #include "langhooks.h" #include "gimple-walk.h" #include "dbgcnt.h" +#include "tree-vector-builder.h" /* Recursively free the memory allocated for the SLP tree rooted at NODE. */ @@ -3222,7 +3223,7 @@ vect_get_constant_vectors (tree op, slp_ number_of_places_left_in_vector = nunits; constant_p = true; - auto_vec elts (nunits); + tree_vector_builder elts (vector_type, nunits, 1); elts.quick_grow (nunits); bool place_after_defs = false; for (j = 0; j < number_of_copies; j++) @@ -3340,7 +3341,7 @@ vect_get_constant_vectors (tree op, slp_ if (number_of_places_left_in_vector == 0) { if (constant_p) - vec_cst = build_vector (vector_type, elts); + vec_cst = elts.build (); else { vec *v; @@ -3371,6 +3372,8 @@ vect_get_constant_vectors (tree op, slp_ place_after_defs = false; number_of_places_left_in_vector = nunits; constant_p = true; + elts.new_vector (vector_type, nunits, 1); + elts.quick_grow (nunits); } } } @@ -3667,11 +3670,11 @@ vect_transform_slp_perm_load (slp_tree n if (! noop_p) { - auto_vec mask_elts (nunits); + tree_vector_builder mask_elts (mask_type, nunits, 1); for (int l = 0; l < nunits; ++l) mask_elts.quick_push (build_int_cst (mask_element_type, mask[l])); - mask_vec = build_vector (mask_type, mask_elts); + mask_vec = mask_elts.build (); } if (second_vec_index == -1) @@ -3823,7 +3826,7 @@ vect_schedule_slp_instance (slp_tree nod for (j = 0; j < v0.length (); ++j) { unsigned int nunits = TYPE_VECTOR_SUBPARTS (vectype); - auto_vec melts (nunits); + tree_vector_builder melts (mvectype, nunits, 1); for (l = 0; l < nunits; ++l) { if (k >= group_size) @@ -3831,7 +3834,7 @@ vect_schedule_slp_instance (slp_tree nod tree t = build_int_cst (meltype, mask[k++] * nunits + l); melts.quick_push (t); } - tmask = build_vector (mvectype, melts); + tmask = melts.build (); /* ??? Not all targets support a VEC_PERM_EXPR with a constant mask that would translate to a vec_merge RTX Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-11-29 11:06:29.970567408 +0000 +++ gcc/tree-vect-stmts.c 2017-12-06 14:48:52.890162093 +0000 @@ -48,6 +48,7 @@ Software Foundation; either version 3, o #include "tree-vectorizer.h" #include "builtins.h" #include "internal-fn.h" +#include "tree-vector-builder.h" /* For lang_hooks.types.type_for_mode. */ #include "langhooks.h" @@ -2520,10 +2521,10 @@ vectorizable_bswap (gimple *stmt, gimple return true; } - auto_vec telts (num_bytes); + tree_vector_builder telts (char_vectype, num_bytes, 1); for (unsigned i = 0; i < num_bytes; ++i) telts.quick_push (build_int_cst (char_type_node, elts[i])); - tree bswap_vconst = build_vector (char_vectype, telts); + tree bswap_vconst = telts.build (); /* Transform. */ vec vec_oprnds = vNULL; @@ -2941,11 +2942,11 @@ vectorizable_call (gimple *gs, gimple_st if (gimple_call_internal_p (stmt) && gimple_call_internal_fn (stmt) == IFN_GOMP_SIMD_LANE) { - auto_vec v (nunits_out); - for (int k = 0; k < nunits_out; ++k) + tree_vector_builder v (vectype_out, 1, 3); + for (int k = 0; k < 3; ++k) v.quick_push (build_int_cst (unsigned_type_node, j * nunits_out + k)); - tree cst = build_vector (vectype_out, v); + tree cst = v.build (); tree new_var = vect_get_new_ssa_name (vectype_out, vect_simple_var, "cst_"); gimple *init_stmt = gimple_build_assign (new_var, cst); @@ -6507,7 +6508,7 @@ vectorizable_store (gimple *stmt, gimple tree vect_gen_perm_mask_any (tree vectype, vec_perm_indices sel) { - tree mask_elt_type, mask_type, mask_vec; + tree mask_elt_type, mask_type; unsigned int nunits = sel.length (); gcc_checking_assert (nunits == TYPE_VECTOR_SUBPARTS (vectype)); @@ -6516,12 +6517,10 @@ vect_gen_perm_mask_any (tree vectype, ve (int_mode_for_mode (TYPE_MODE (TREE_TYPE (vectype))).require (), 1); mask_type = get_vectype_for_scalar_type (mask_elt_type); - auto_vec mask_elts (nunits); + tree_vector_builder mask_elts (mask_type, nunits, 1); for (unsigned int i = 0; i < nunits; ++i) mask_elts.quick_push (build_int_cst (mask_elt_type, sel[i])); - mask_vec = build_vector (mask_type, mask_elts); - - return mask_vec; + return mask_elts.build (); } /* Checked version of vect_gen_perm_mask_any. Asserts can_vec_perm_p, Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-12-06 14:46:14.132599861 +0000 +++ gcc/tree.c 2017-12-06 14:48:52.891162052 +0000 @@ -1757,7 +1757,7 @@ build_vector_from_ctor (tree type, vec vec (nelts); + tree_vector_builder vec (type, nelts, 1); FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) { if (TREE_CODE (value) == VECTOR_CST) @@ -1769,7 +1769,7 @@ build_vector_from_ctor (tree type, vec v (nunits); - for (i = 0; i < nunits; ++i) - v.quick_push (sc); - return build_vector (vectype, v); + tree_vector_builder v (vectype, 1, 1); + v.quick_push (sc); + return v.build (); } else {