From patchwork Fri Sep 22 16:34:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 114061 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3493823qgf; Fri, 22 Sep 2017 09:35:00 -0700 (PDT) X-Received: by 10.99.163.67 with SMTP id v3mr9840094pgn.206.1506098100052; Fri, 22 Sep 2017 09:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506098100; cv=none; d=google.com; s=arc-20160816; b=jJEG+gmAlYZAT5gRxQNhprqlCRzvn9MkzL4++wGef2RRzi1g//IX+ty4J7ch0ykovn Doyx0ft0SS8N6qlVGN1fxiGEd3i8qX/YTvvN4ASX1l43MzU2R0Q8pazLPCFEgOgMiV3H cQzsQVSvIY1fiHKfX+jb/qkZDXdGJHeKm/QpNsa8+mzhyR7WrDtd9Y72LTTelL8v1YpR u0ReBGoCFLpvWq8Xp643rGSPBOoW4hFsrpGd+fEzrlJMiDZfnjAT2P3xYVhJb6SG0mGg aVdsWzTh8uzuGeJ1Ty518WLJY3UY6QUg/ebz25bu6pKYpHpADXztj0CQ2uhBgxMfAfkB Lu9Q== 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=31AHCnzQiqui4t9mXqzWpEFciXkDLjfrftY3EdV5f0g=; b=fLMCWn9BjzGAXoYQlhUn1S4PloZzaIxSQMR1RB4P2dmC2ep+ejimwCCcKMco22qQNJ kcpwUfn9e6R6qDwBCoV8xOQt/DWyCmwjJ8/GVJZFNdzalliUJyiFIS431VpxNbV7tI1w 0GrEHkRzR+qvPl545FEjacxJR8lOIFdKWfP2pP5plkzvoQrf4McO1L1MnbPaeOx78kax kmc762bfF65/uLUVoGrZnpyryaId9kNj/he1ljWTkSSaYBUfRwkfH3FO4X/r+M+PFUEm VviSXORNqJBJf5SY2ubUKG07c2fr5gqgTfGF4vASwEV3I0YWhwJKhycGVdkAcv/9RChr DHEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tj+MV0yh; spf=pass (google.com: domain of gcc-patches-return-462792-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462792-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 h22si100321pli.513.2017.09.22.09.34.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 09:35:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462792-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=tj+MV0yh; spf=pass (google.com: domain of gcc-patches-return-462792-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462792-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=s8c3j+XTFKX01Vu49L10DMOZ/bGO4svdwDwUyvGAlBn+8mLLjU/ej WDAGFqbBTseXzll9ns7ecpGEwIjRQDWLvuVoPjeox/LJ7VqwkaX1mtQqYEAgcIUp Tf/jegKQrryx1uxyXC6AFwA/kpCpuYHlnsr8De8GfUPXR2UTOWsaHo= 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=GwfqX50OGZVg4AC5bLwGTv5JJyI=; b=tj+MV0yhxO44SzXINVVw 5K4Dq1+g1bSe9GRpHcok9QBcdsDa8hihS3ZYIa9uEwMcr1xny/O6TQWsah98lk8y hHcmJSaLekCin2R/4z9NPd4aJseuEwE1B6yX3TsuJ3nE9tZ6Aw+C4LKIxOVjwRQe MpLhNtxtlyQTYTudAkRZ8q0= Received: (qmail 119799 invoked by alias); 22 Sep 2017 16:34:45 -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 119786 invoked by uid 89); 22 Sep 2017 16:34:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, 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=HX-Received:10.223.142.199, operan X-HELO: mail-wr0-f182.google.com Received: from mail-wr0-f182.google.com (HELO mail-wr0-f182.google.com) (209.85.128.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Sep 2017 16:34:41 +0000 Received: by mail-wr0-f182.google.com with SMTP id w12so1335942wrc.7 for ; Fri, 22 Sep 2017 09:34:40 -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=31AHCnzQiqui4t9mXqzWpEFciXkDLjfrftY3EdV5f0g=; b=DxHNWoPVnFT039tpeoEIWJnvrAWIUAY6fQ90L68No3rBjE8sxxpcPV5kzf6x0z5HjX Q5TdACd281weajLTPJmHrHeWm2aCFIJY4m36Y75+FAbKjeGSV7B37PoqTcJkiFzix9t6 4Rs6hmgxbpRupyVTRwtcB3EkRQ6Lg+8AYLfxEEEAx0JlLG79TkaStwkM8A8TtuNOI4Jj wEsYW1S0Xanvz38JD9w8yjAUysS7R/nwKHLXIlRPcc3hzWxJBznE8JrT6KLsUDLqwWYP L50V567ze/sZy52GeIFZvQisF6+scOERtU0Sb7oXS8zf0M5KNSdQ6HWti5sjNr/AQobx IXJg== X-Gm-Message-State: AHPjjUjWZFPPhSu3LwlN1GXy6DI+6xIPgMdNMkuGRtWaqFsjNsiaDCH9 cA6U7uOtxk6SCGMJJ0WA66NiH2MpbEM= X-Google-Smtp-Source: AOwi7QClPOiv9u1b2r2rVsDRcO8oy1rFR7cnbFN/JQJzPT06uybE43zo3cwEF9Iir1phaLsOHtKXJg== X-Received: by 10.223.142.199 with SMTP id q65mr5966383wrb.110.1506098078028; Fri, 22 Sep 2017 09:34:38 -0700 (PDT) Received: from localhost (94.197.121.89.threembb.co.uk. [94.197.121.89]) by smtp.gmail.com with ESMTPSA id 30sm289235wry.34.2017.09.22.09.34.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Sep 2017 09:34:37 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Update interface to TARGET_VECTORIZE_VEC_PERM_CONST_OK Date: Fri, 22 Sep 2017 17:34:34 +0100 Message-ID: <87a81mr8th.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes TARGET_VECTORIZE_VEC_PERM_CONST_OK take the permute vector in the form of a vec_perm_indices instead of an unsigned char *. It follows on from the recent patch that did the same in target-independent code. It was easy to make ARM and AArch64 use vec_perm_indices internally as well, and converting AArch64 helps with SVE. I did try doing the same for the other ports, but the surgery needed was much more invasive and much less obviously correct. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also tested by comparing the testsuite assembly output on at least one target per CPU directory. OK to install? Richard 2017-09-22 Richard Sandiford gcc/ * target.def (vec_perm_const_ok): Change sel parameter to vec_perm_indices. * optabs-query.c (can_vec_perm_p): Update accordingly. * doc/tm.texi: Regenerate. * config/aarch64/aarch64.c (expand_vec_perm_d): Change perm to auto_vec_perm_indices and remove separate nelt field. (aarch64_evpc_trn, aarch64_evpc_uzp, aarch64_evpc_zip) (aarch64_evpc_ext, aarch64_evpc_rev, aarch64_evpc_dup) (aarch64_evpc_tbl, aarch64_expand_vec_perm_const_1) (aarch64_expand_vec_perm_const): Update accordingly. (aarch64_vectorize_vec_perm_const_ok): Likewise. Change sel to vec_perm_indices. * config/arm/arm.c (expand_vec_perm_d): Change perm to auto_vec_perm_indices and remove separate nelt field. (arm_evpc_neon_vuzp, arm_evpc_neon_vzip, arm_evpc_neon_vrev) (arm_evpc_neon_vtrn, arm_evpc_neon_vext, arm_evpc_neon_vtbl) (arm_expand_vec_perm_const_1, arm_expand_vec_perm_const): Update accordingly. (arm_vectorize_vec_perm_const_ok): Likewise. Change sel to vec_perm_indices. * config/i386/i386.c (ix86_vectorize_vec_perm_const_ok): Change sel to vec_perm_indices. * config/ia64/ia64.c (ia64_vectorize_vec_perm_const_ok): Likewise. * config/mips/mips.c (mips_vectorize_vec_perm_const_ok): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_vectorize_vec_perm_const_ok): Likewise. * config/rs6000/rs6000.c (rs6000_vectorize_vec_perm_const_ok): Likewise. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-09-22 17:31:36.935337179 +0100 +++ gcc/target.def 2017-09-22 17:31:56.428954480 +0100 @@ -1847,7 +1847,7 @@ DEFHOOK DEFHOOK (vec_perm_const_ok, "Return true if a vector created for @code{vec_perm_const} is valid.", - bool, (machine_mode, const unsigned char *sel), + bool, (machine_mode, vec_perm_indices), NULL) /* Return true if the target supports misaligned store/load of a Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-09-14 17:04:19.080694343 +0100 +++ gcc/optabs-query.c 2017-09-22 17:31:56.428006577 +0100 @@ -367,7 +367,7 @@ can_vec_perm_p (machine_mode mode, bool if (direct_optab_handler (vec_perm_const_optab, mode) != CODE_FOR_nothing && (sel == NULL || targetm.vectorize.vec_perm_const_ok == NULL - || targetm.vectorize.vec_perm_const_ok (mode, &(*sel)[0]))) + || targetm.vectorize.vec_perm_const_ok (mode, *sel))) return true; } Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-09-22 17:31:36.933441374 +0100 +++ gcc/doc/tm.texi 2017-09-22 17:31:56.428006577 +0100 @@ -5774,7 +5774,7 @@ correct for most targets. Return true if vector alignment is reachable (by peeling N iterations) for the given scalar type @var{type}. @var{is_packed} is false if the scalar access using @var{type} is known to be naturally aligned. @end deftypefn -@deftypefn {Target Hook} bool TARGET_VECTORIZE_VEC_PERM_CONST_OK (machine_mode, const unsigned char *@var{sel}) +@deftypefn {Target Hook} bool TARGET_VECTORIZE_VEC_PERM_CONST_OK (machine_mode, @var{vec_perm_indices}) Return true if a vector created for @code{vec_perm_const} is valid. @end deftypefn Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-09-21 11:53:16.681759682 +0100 +++ gcc/config/aarch64/aarch64.c 2017-09-22 17:31:56.412840135 +0100 @@ -141,8 +141,8 @@ static void aarch64_elf_asm_constructor static void aarch64_elf_asm_destructor (rtx, int) ATTRIBUTE_UNUSED; static void aarch64_override_options_after_change (void); static bool aarch64_vector_mode_supported_p (machine_mode); -static bool aarch64_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel); +static bool aarch64_vectorize_vec_perm_const_ok (machine_mode, + vec_perm_indices); static int aarch64_address_cost (rtx, machine_mode, addr_space_t, bool); static bool aarch64_builtin_support_vector_misalignment (machine_mode mode, const_tree type, @@ -13146,9 +13146,8 @@ #define MAX_VECT_LEN 16 struct expand_vec_perm_d { rtx target, op0, op1; - unsigned char perm[MAX_VECT_LEN]; + auto_vec_perm_indices perm; machine_mode vmode; - unsigned char nelt; bool one_vector_p; bool testing_p; }; @@ -13231,7 +13230,7 @@ aarch64_expand_vec_perm (rtx target, rtx static bool aarch64_evpc_trn (struct expand_vec_perm_d *d) { - unsigned int i, odd, mask, nelt = d->nelt; + unsigned int i, odd, mask, nelt = d->perm.length (); rtx out, in0, in1, x; rtx (*gen) (rtx, rtx, rtx); machine_mode vmode = d->vmode; @@ -13319,7 +13318,7 @@ aarch64_evpc_trn (struct expand_vec_perm static bool aarch64_evpc_uzp (struct expand_vec_perm_d *d) { - unsigned int i, odd, mask, nelt = d->nelt; + unsigned int i, odd, mask, nelt = d->perm.length (); rtx out, in0, in1, x; rtx (*gen) (rtx, rtx, rtx); machine_mode vmode = d->vmode; @@ -13406,7 +13405,7 @@ aarch64_evpc_uzp (struct expand_vec_perm static bool aarch64_evpc_zip (struct expand_vec_perm_d *d) { - unsigned int i, high, mask, nelt = d->nelt; + unsigned int i, high, mask, nelt = d->perm.length (); rtx out, in0, in1, x; rtx (*gen) (rtx, rtx, rtx); machine_mode vmode = d->vmode; @@ -13499,7 +13498,7 @@ aarch64_evpc_zip (struct expand_vec_perm static bool aarch64_evpc_ext (struct expand_vec_perm_d *d) { - unsigned int i, nelt = d->nelt; + unsigned int i, nelt = d->perm.length (); rtx (*gen) (rtx, rtx, rtx, rtx); rtx offset; @@ -13563,7 +13562,7 @@ aarch64_evpc_ext (struct expand_vec_perm static bool aarch64_evpc_rev (struct expand_vec_perm_d *d) { - unsigned int i, j, diff, nelt = d->nelt; + unsigned int i, j, diff, nelt = d->perm.length (); rtx (*gen) (rtx, rtx); if (!d->one_vector_p) @@ -13641,7 +13640,7 @@ aarch64_evpc_dup (struct expand_vec_perm rtx out = d->target; rtx in0; machine_mode vmode = d->vmode; - unsigned int i, elt, nelt = d->nelt; + unsigned int i, elt, nelt = d->perm.length (); rtx lane; elt = d->perm[0]; @@ -13686,7 +13685,7 @@ aarch64_evpc_tbl (struct expand_vec_perm { rtx rperm[MAX_VECT_LEN], sel; machine_mode vmode = d->vmode; - unsigned int i, nelt = d->nelt; + unsigned int i, nelt = d->perm.length (); if (d->testing_p) return true; @@ -13720,12 +13719,11 @@ aarch64_expand_vec_perm_const_1 (struct /* The pattern matching functions above are written to look for a small number to begin the sequence (0, 1, N/2). If we begin with an index from the second operand, we can swap the operands. */ - if (d->perm[0] >= d->nelt) + unsigned int nelt = d->perm.length (); + if (d->perm[0] >= nelt) { - unsigned i, nelt = d->nelt; - gcc_assert (nelt == (nelt & -nelt)); - for (i = 0; i < nelt; ++i) + for (unsigned int i = 0; i < nelt; ++i) d->perm[i] ^= nelt; /* Keep the same index, but in the other vector. */ std::swap (d->op0, d->op1); @@ -13764,15 +13762,16 @@ aarch64_expand_vec_perm_const (rtx targe d.vmode = GET_MODE (target); gcc_assert (VECTOR_MODE_P (d.vmode)); - d.nelt = nelt = GET_MODE_NUNITS (d.vmode); d.testing_p = false; + nelt = GET_MODE_NUNITS (d.vmode); + d.perm.reserve (nelt); for (i = which = 0; i < nelt; ++i) { rtx e = XVECEXP (sel, 0, i); int ei = INTVAL (e) & (2 * nelt - 1); which |= (ei < nelt ? 1 : 2); - d.perm[i] = ei; + d.perm.quick_push (ei); } switch (which) @@ -13807,19 +13806,18 @@ aarch64_expand_vec_perm_const (rtx targe } static bool -aarch64_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel) +aarch64_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) { struct expand_vec_perm_d d; unsigned int i, nelt, which; bool ret; d.vmode = vmode; - d.nelt = nelt = GET_MODE_NUNITS (d.vmode); d.testing_p = true; - memcpy (d.perm, sel, nelt); + d.perm.safe_splice (sel); /* Calculate whether all elements are in one vector. */ + nelt = sel.length (); for (i = which = 0; i < nelt; ++i) { unsigned char e = d.perm[i]; Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-09-22 17:22:08.191305805 +0100 +++ gcc/config/arm/arm.c 2017-09-22 17:31:56.414735941 +0100 @@ -287,8 +287,7 @@ static int arm_cortex_a5_branch_cost (bo static int arm_cortex_m_branch_cost (bool, bool); static int arm_cortex_m7_branch_cost (bool, bool); -static bool arm_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel); +static bool arm_vectorize_vec_perm_const_ok (machine_mode, vec_perm_indices); static bool aarch_macro_fusion_pair_p (rtx_insn*, rtx_insn*); @@ -28657,9 +28656,8 @@ #define MAX_VECT_LEN 16 struct expand_vec_perm_d { rtx target, op0, op1; - unsigned char perm[MAX_VECT_LEN]; + auto_vec_perm_indices perm; machine_mode vmode; - unsigned char nelt; bool one_vector_p; bool testing_p; }; @@ -28766,7 +28764,7 @@ neon_pair_endian_lane_map (machine_mode static bool arm_evpc_neon_vuzp (struct expand_vec_perm_d *d) { - unsigned int i, odd, mask, nelt = d->nelt; + unsigned int i, odd, mask, nelt = d->perm.length (); rtx out0, out1, in0, in1; rtx (*gen)(rtx, rtx, rtx, rtx); int first_elem; @@ -28778,7 +28776,7 @@ arm_evpc_neon_vuzp (struct expand_vec_pe /* arm_expand_vec_perm_const_1 () helpfully swaps the operands for the big endian pattern on 64 bit vectors, so we correct for that. */ swap_nelt = BYTES_BIG_ENDIAN && !d->one_vector_p - && GET_MODE_SIZE (d->vmode) == 8 ? d->nelt : 0; + && GET_MODE_SIZE (d->vmode) == 8 ? nelt : 0; first_elem = d->perm[neon_endian_lane_map (d->vmode, 0)] ^ swap_nelt; @@ -28837,7 +28835,7 @@ arm_evpc_neon_vuzp (struct expand_vec_pe static bool arm_evpc_neon_vzip (struct expand_vec_perm_d *d) { - unsigned int i, high, mask, nelt = d->nelt; + unsigned int i, high, mask, nelt = d->perm.length (); rtx out0, out1, in0, in1; rtx (*gen)(rtx, rtx, rtx, rtx); int first_elem; @@ -28912,7 +28910,7 @@ arm_evpc_neon_vzip (struct expand_vec_pe static bool arm_evpc_neon_vrev (struct expand_vec_perm_d *d) { - unsigned int i, j, diff, nelt = d->nelt; + unsigned int i, j, diff, nelt = d->perm.length (); rtx (*gen)(rtx, rtx); if (!d->one_vector_p) @@ -28988,7 +28986,7 @@ arm_evpc_neon_vrev (struct expand_vec_pe static bool arm_evpc_neon_vtrn (struct expand_vec_perm_d *d) { - unsigned int i, odd, mask, nelt = d->nelt; + unsigned int i, odd, mask, nelt = d->perm.length (); rtx out0, out1, in0, in1; rtx (*gen)(rtx, rtx, rtx, rtx); @@ -29054,7 +29052,7 @@ arm_evpc_neon_vtrn (struct expand_vec_pe static bool arm_evpc_neon_vext (struct expand_vec_perm_d *d) { - unsigned int i, nelt = d->nelt; + unsigned int i, nelt = d->perm.length (); rtx (*gen) (rtx, rtx, rtx, rtx); rtx offset; @@ -29128,7 +29126,7 @@ arm_evpc_neon_vtbl (struct expand_vec_pe { rtx rperm[MAX_VECT_LEN], sel; machine_mode vmode = d->vmode; - unsigned int i, nelt = d->nelt; + unsigned int i, nelt = d->perm.length (); /* TODO: ARM's VTBL indexing is little-endian. In order to handle GCC's numbering of elements for big-endian, we must reverse the order. */ @@ -29165,11 +29163,10 @@ arm_expand_vec_perm_const_1 (struct expa /* The pattern matching functions above are written to look for a small number to begin the sequence (0, 1, N/2). If we begin with an index from the second operand, we can swap the operands. */ - if (d->perm[0] >= d->nelt) + unsigned int nelt = d->perm.length (); + if (d->perm[0] >= nelt) { - unsigned i, nelt = d->nelt; - - for (i = 0; i < nelt; ++i) + for (unsigned int i = 0; i < nelt; ++i) d->perm[i] = (d->perm[i] + nelt) & (2 * nelt - 1); std::swap (d->op0, d->op1); @@ -29204,15 +29201,16 @@ arm_expand_vec_perm_const (rtx target, r d.vmode = GET_MODE (target); gcc_assert (VECTOR_MODE_P (d.vmode)); - d.nelt = nelt = GET_MODE_NUNITS (d.vmode); d.testing_p = false; + nelt = GET_MODE_NUNITS (d.vmode); + d.perm.reserve (nelt); for (i = which = 0; i < nelt; ++i) { rtx e = XVECEXP (sel, 0, i); int ei = INTVAL (e) & (2 * nelt - 1); which |= (ei < nelt ? 1 : 2); - d.perm[i] = ei; + d.perm.quick_push (ei); } switch (which) @@ -29249,19 +29247,18 @@ arm_expand_vec_perm_const (rtx target, r /* Implement TARGET_VECTORIZE_VEC_PERM_CONST_OK. */ static bool -arm_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel) +arm_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) { struct expand_vec_perm_d d; unsigned int i, nelt, which; bool ret; d.vmode = vmode; - d.nelt = nelt = GET_MODE_NUNITS (d.vmode); d.testing_p = true; - memcpy (d.perm, sel, nelt); + d.perm.safe_splice (sel); /* Categorize the set of elements in the selector. */ + nelt = GET_MODE_NUNITS (d.vmode); for (i = which = 0; i < nelt; ++i) { unsigned char e = d.perm[i]; Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-09-22 17:22:08.149305815 +0100 +++ gcc/config/i386/i386.c 2017-09-22 17:31:56.418527551 +0100 @@ -50024,8 +50024,7 @@ ix86_expand_vec_perm_const (rtx operands /* Implement targetm.vectorize.vec_perm_const_ok. */ static bool -ix86_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel) +ix86_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) { struct expand_vec_perm_d d; unsigned int i, nelt, which; @@ -50096,11 +50095,11 @@ ix86_vectorize_vec_perm_const_ok (machin /* Extract the values from the vector CST into the permutation array in D. */ - memcpy (d.perm, sel, nelt); for (i = which = 0; i < nelt; ++i) { - unsigned char e = d.perm[i]; + unsigned char e = sel[i]; gcc_assert (e < 2 * nelt); + d.perm[i] = e; which |= (e < nelt ? 1 : 2); } Index: gcc/config/ia64/ia64.c =================================================================== --- gcc/config/ia64/ia64.c 2017-09-21 11:53:16.654742357 +0100 +++ gcc/config/ia64/ia64.c 2017-09-22 17:31:56.419475454 +0100 @@ -333,8 +333,7 @@ static machine_mode ia64_get_reg_raw_mod static section * ia64_hpux_function_section (tree, enum node_frequency, bool, bool); -static bool ia64_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel); +static bool ia64_vectorize_vec_perm_const_ok (machine_mode, vec_perm_indices); static unsigned int ia64_hard_regno_nregs (unsigned int, machine_mode); static bool ia64_hard_regno_mode_ok (unsigned int, machine_mode); @@ -11824,8 +11823,7 @@ ia64_expand_vec_perm_const (rtx operands /* Implement targetm.vectorize.vec_perm_const_ok. */ static bool -ia64_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel) +ia64_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) { struct expand_vec_perm_d d; unsigned int i, nelt, which; @@ -11837,10 +11835,10 @@ ia64_vectorize_vec_perm_const_ok (machin /* Extract the values from the vector CST into the permutation array in D. */ - memcpy (d.perm, sel, nelt); for (i = which = 0; i < nelt; ++i) { - unsigned char e = d.perm[i]; + unsigned char e = sel[i]; + d.perm[i] = e; gcc_assert (e < 2 * nelt); which |= (e < nelt ? 1 : 2); } Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2017-09-21 11:53:16.776320319 +0100 +++ gcc/config/mips/mips.c 2017-09-22 17:31:56.421371259 +0100 @@ -21470,8 +21470,7 @@ mips_sched_reassociation_width (unsigned /* Implement TARGET_VECTORIZE_VEC_PERM_CONST_OK. */ static bool -mips_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel) +mips_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) { struct expand_vec_perm_d d; unsigned int i, nelt, which; @@ -21480,12 +21479,12 @@ mips_vectorize_vec_perm_const_ok (machin d.vmode = vmode; d.nelt = nelt = GET_MODE_NUNITS (d.vmode); d.testing_p = true; - memcpy (d.perm, sel, nelt); /* Categorize the set of elements in the selector. */ for (i = which = 0; i < nelt; ++i) { - unsigned char e = d.perm[i]; + unsigned char e = sel[i]; + d.perm[i] = e; gcc_assert (e < 2 * nelt); which |= (e < nelt ? 1 : 2); } Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-09-21 11:53:16.643935427 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-09-22 17:31:56.424214967 +0100 @@ -38731,8 +38731,7 @@ rs6000_expand_vec_perm_const (rtx operan /* Test whether a constant permutation is supported. */ static bool -rs6000_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel) +rs6000_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) { /* AltiVec (and thus VSX) can handle arbitrary permutations. */ if (TARGET_ALTIVEC) Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-09-21 11:53:16.730390867 +0100 +++ gcc/config/rs6000/rs6000.c 2017-09-22 17:31:56.427058675 +0100 @@ -35594,8 +35594,7 @@ rs6000_expand_vec_perm_const (rtx operan /* Test whether a constant permutation is supported. */ static bool -rs6000_vectorize_vec_perm_const_ok (machine_mode vmode, - const unsigned char *sel) +rs6000_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) { /* AltiVec (and thus VSX) can handle arbitrary permutations. */ if (TARGET_ALTIVEC)