From patchwork Mon Sep 4 11:39:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 111546 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp4116569ybm; Mon, 4 Sep 2017 04:39:52 -0700 (PDT) X-Received: by 10.99.38.4 with SMTP id m4mr140372pgm.53.1504525192473; Mon, 04 Sep 2017 04:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504525192; cv=none; d=google.com; s=arc-20160816; b=I/LQgVEY1sQ5sr+z+/+clsNIZyeA5KGe4BcnjrduCLsf0jnjQpSSOSg+hpr5um/NVw YYqEZyNlvPekkdc+1rAufn+Vr9TMUN0SNNwLbTUFLjDBQL/K23SjhetvhrcdYW4HW2g0 H/tk+Dt8sDIt8OuLGDtXt918Oj11AblmzEpYB+r8x0tTORicwrkDHORueKpUAL2vg4h1 hXUNBMB9PmFpBia9Qg8YY2h6R5Hf/V5gSsSOVEJVPjJKykp7Mwn4+ThDXcjc0CyC5dK0 ef7j4pOxBo1NA505DwZVjrp5ymn3x9Zshmulsni2VtMgLiIvoel8dEW0PYixXdRcRUNa zhtg== 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=9Q4lZm9oQLSdoJghrdwkeYXTKu8uRndI+oeTuF296ko=; b=yeaETd2kFHOW53ww+MxEMUzeRwHPW5mhHRxXqvkiQrqh/7a2ZhkQKfP9pnSdJWYU2M avR1JjjBtT7IRUpC7UTVSGvnW07Vh//XjCPRMkgENxPl/vbNgP5hchpPzOIA+5Kv+pE9 2k8FabomwW6moZDVpohSPUYouteavq+KxjHTKi0t3rm0qhmt+35sxWHdVNJ/jBvcWZbx j0SwheFETxSiH4x4UdFTYCZT6Abrw0jpqgOBWEK/qrNZm1Y9tzoW8Jmwso7r2I50aar5 PPR/KaU3xCSxO7FqiKtEbMqWydv/C/2W0WHhKsK/5aFksdPOw592m3gkYUBZuHB5dmvH rhKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=IZzxnm8i; spf=pass (google.com: domain of gcc-patches-return-461409-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461409-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 u10si5329544plm.706.2017.09.04.04.39.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Sep 2017 04:39:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-461409-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=IZzxnm8i; spf=pass (google.com: domain of gcc-patches-return-461409-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461409-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=joI69w8HPJflg4oJmHVP36pISTqRi 4dLNYyEWAl1BOReannlSI37tn6GKcSv0UtzI8wZECsh+jsex+iuWXzJk8vZAEwCu pnFNSv9M1Ng572De3S7flx4hbvHUo3YNXej19JXIMYx81OW4Xug/wOsR9RtmGFuM UTAKikcXljBnos= 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=HvK+rnrGMiSBns41WJRUPdTceKs=; b=IZz xnm8iHX1zqUf5i3gCM2j/cWKGS3Zj/FvOkYCmGUkUIP4yV+IgGLbrjHdh6cIi8E8 0WQAQ6I7s4dp1yi1DP3DEBIQaSBQhT4Be4RabjqR8K9BNl0h3h+FEt0e7vvqqrES ihIVOub+eoaDwJxHfxNr27rJ3iR2Kzu5oy9n4Fms= Received: (qmail 95422 invoked by alias); 4 Sep 2017 11:39:38 -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 95144 invoked by uid 89); 4 Sep 2017 11:39:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 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-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Sep 2017 11:39:32 +0000 Received: by mail-wm0-f46.google.com with SMTP id v2so3320017wmf.0 for ; Mon, 04 Sep 2017 04:39:31 -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=9Q4lZm9oQLSdoJghrdwkeYXTKu8uRndI+oeTuF296ko=; b=YtVfJWaIFmHvxLQh8mMJcn61mz9bxaKDL6usfPzHnJtYTsMVJq3uMP9JOKFtGX4XHR ZyEQSfTBkH9wUP18DuhO1pNMaQgklvXv0BvJZISC6/QRCeZmmXYYhZ8Bd6fXonjmSvVX alrv3DzdRNV0n9JAprUtjIY4HrqDkK4qaL8UzSKUXFjuu/2zi/KvhqNtOFpZya8Got5D V0j2D/+NQWMoqIN0TMxZpWBa9nLyn7GETcrWeq8lgROOy5Qq5FUvAbtORmurH4/LYZSJ RSWuqB8dTskZb7xilvX+7418kOx0P34uA5xAxcczXp0uu93Zl4hot6a69Hgogdtr6nMk gW/Q== X-Gm-Message-State: AHPjjUjD9YXI3BAQxgwdBvxUHD+SqqQR9Ixje0dVhlDpETHLn0RGf63o HFupR2ymlF9D2FZK8ZQkrg== X-Google-Smtp-Source: ADKCNb7J2QCWEpcf9LJwxH/nh9XmmxtZ88gMVO8dvkRFkoHVku3k5sd1oStx4eUi1Dc9VjzOfs2kBg== X-Received: by 10.28.183.8 with SMTP id h8mr399905wmf.24.1504525168769; Mon, 04 Sep 2017 04:39:28 -0700 (PDT) Received: from localhost (94.197.120.41.threembb.co.uk. [94.197.120.41]) by smtp.gmail.com with ESMTPSA id b10sm3239811wrc.69.2017.09.04.04.39.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Sep 2017 04:39:28 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [6/9] Make mode_for_vector return an opt_mode References: <87tw0iiu51.fsf@linaro.org> Date: Mon, 04 Sep 2017 12:39:23 +0100 In-Reply-To: <87tw0iiu51.fsf@linaro.org> (Richard Sandiford's message of "Mon, 04 Sep 2017 12:24:26 +0100") Message-ID: <873782itg4.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 ...following on from the mode_for_size change. The patch also removes machmode.h versions of the stor-layout.c comments, since the comments in the .c file are more complete. 2017-09-04 Richard Sandiford gcc/ * machmode.h (mode_for_vector): Return an opt_mode. * stor-layout.c (mode_for_vector): Likewise. (mode_for_int_vector): Update accordingly. (layout_type): Likewise. * config/i386/i386.c (emit_memmov): Likewise. (ix86_expand_set_or_movmem): Likewise. (ix86_expand_vector_init): Likewise. (ix86_get_mask_mode): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_expand_vec_perm_const_1): Likewise. * config/rs6000/rs6000.c (rs6000_expand_vec_perm_const_1): Likewise. * expmed.c (extract_bit_field_1): Likewise. * expr.c (expand_expr_real_2): Likewise. * optabs-query.c (can_vec_perm_p): Likewise. (can_vec_mask_load_store_p): Likewise. * optabs.c (expand_vec_perm): Likewise. * targhooks.c (default_get_mask_mode): Likewise. * tree-vect-stmts.c (vectorizable_store): Likewise. (vectorizable_load): Likewise. (get_vectype_for_scalar_type_and_size): Likewise. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-09-04 12:18:53.153306182 +0100 +++ gcc/machmode.h 2017-09-04 12:18:55.821333642 +0100 @@ -682,8 +682,6 @@ decimal_float_mode_for_size (unsigned in (mode_for_size (size, MODE_DECIMAL_FLOAT, 0)); } -/* Similar to mode_for_size, but find the smallest mode for a given width. */ - extern machine_mode smallest_mode_for_size (unsigned int, enum mode_class); /* Find the narrowest integer mode that contains at least SIZE bits. @@ -695,17 +693,9 @@ smallest_int_mode_for_size (unsigned int return as_a (smallest_mode_for_size (size, MODE_INT)); } -/* Return an integer mode of exactly the same size as the input mode. */ - extern opt_scalar_int_mode int_mode_for_mode (machine_mode); - extern machine_mode bitwise_mode_for_mode (machine_mode); - -/* Return a mode that is suitable for representing a vector, - or BLKmode on failure. */ - -extern machine_mode mode_for_vector (scalar_mode, unsigned); - +extern opt_machine_mode mode_for_vector (scalar_mode, unsigned); extern opt_machine_mode mode_for_int_vector (unsigned int, unsigned int); /* Return the integer vector equivalent of MODE, if one exists. In other Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-09-04 12:18:53.153306182 +0100 +++ gcc/stor-layout.c 2017-09-04 12:18:55.824344959 +0100 @@ -471,11 +471,11 @@ bitwise_type_for_mode (machine_mode mode return inner_type; } -/* Find a mode that is suitable for representing a vector with - NUNITS elements of mode INNERMODE. Returns BLKmode if there - is no suitable mode. */ +/* Find a mode that is suitable for representing a vector with NUNITS + elements of mode INNERMODE, if one exists. The returned mode can be + either an integer mode or a vector mode. */ -machine_mode +opt_machine_mode mode_for_vector (scalar_mode innermode, unsigned nunits) { machine_mode mode; @@ -499,22 +499,18 @@ mode_for_vector (scalar_mode innermode, FOR_EACH_MODE_FROM (mode, mode) if (GET_MODE_NUNITS (mode) == nunits && GET_MODE_INNER (mode) == innermode) - break; + return mode; /* For integers, try mapping it to a same-sized scalar mode. */ - if (mode == VOIDmode - && GET_MODE_CLASS (innermode) == MODE_INT) + if (GET_MODE_CLASS (innermode) == MODE_INT) { unsigned int nbits = nunits * GET_MODE_BITSIZE (innermode); - mode = int_mode_for_size (nbits, 0).else_blk (); + if (int_mode_for_size (nbits, 0).exists (&mode) + && have_regs_of_mode[mode]) + return mode; } - if (mode == VOIDmode - || (GET_MODE_CLASS (mode) == MODE_INT - && !have_regs_of_mode[mode])) - return BLKmode; - - return mode; + return opt_machine_mode (); } /* Return the mode for a vector that has NUNITS integer elements of @@ -525,12 +521,10 @@ mode_for_vector (scalar_mode innermode, mode_for_int_vector (unsigned int int_bits, unsigned int nunits) { scalar_int_mode int_mode; - if (int_mode_for_size (int_bits, 0).exists (&int_mode)) - { - machine_mode vec_mode = mode_for_vector (int_mode, nunits); - if (vec_mode != BLKmode) - return vec_mode; - } + machine_mode vec_mode; + if (int_mode_for_size (int_bits, 0).exists (&int_mode) + && mode_for_vector (int_mode, nunits).exists (&vec_mode)) + return vec_mode; return opt_machine_mode (); } @@ -2264,7 +2258,7 @@ layout_type (tree type) if (TYPE_MODE (type) == VOIDmode) SET_TYPE_MODE (type, mode_for_vector (SCALAR_TYPE_MODE (innertype), - nunits)); + nunits).else_blk ()); TYPE_SATURATING (type) = TYPE_SATURATING (TREE_TYPE (type)); TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TREE_TYPE (type)); Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-09-04 12:18:44.903326171 +0100 +++ gcc/config/i386/i386.c 2017-09-04 12:18:55.808284598 +0100 @@ -27420,9 +27420,8 @@ emit_memmov (rtx destmem, rtx *srcmem, r if (GET_MODE_SIZE (move_mode) > GET_MODE_SIZE (word_mode)) { int nunits = GET_MODE_SIZE (move_mode) / GET_MODE_SIZE (word_mode); - move_mode = mode_for_vector (word_mode, nunits); - code = optab_handler (mov_optab, move_mode); - if (code == CODE_FOR_nothing) + if (!mode_for_vector (word_mode, nunits).exists (&move_mode) + || (code = optab_handler (mov_optab, move_mode)) == CODE_FOR_nothing) { move_mode = word_mode; piece_size = GET_MODE_SIZE (move_mode); @@ -28654,8 +28653,8 @@ ix86_expand_set_or_movmem (rtx dst, rtx if (GET_MODE_SIZE (move_mode) > GET_MODE_SIZE (word_mode)) { int nunits = GET_MODE_SIZE (move_mode) / GET_MODE_SIZE (word_mode); - move_mode = mode_for_vector (word_mode, nunits); - if (optab_handler (mov_optab, move_mode) == CODE_FOR_nothing) + if (!mode_for_vector (word_mode, nunits).exists (&move_mode) + || optab_handler (mov_optab, move_mode) == CODE_FOR_nothing) move_mode = word_mode; } gcc_assert (optab_handler (mov_optab, move_mode) != CODE_FOR_nothing); @@ -44497,11 +44496,9 @@ ix86_expand_vector_init (bool mmx_ok, rt rtx ops[2] = { XVECEXP (vals, 0, 0), XVECEXP (vals, 0, 1) }; if (inner_mode == QImode || inner_mode == HImode) { - mode = mode_for_vector (SImode, - n_elts * GET_MODE_SIZE (inner_mode) / 4); - inner_mode - = mode_for_vector (SImode, - n_elts * GET_MODE_SIZE (inner_mode) / 8); + unsigned int n_bits = n_elts * GET_MODE_SIZE (inner_mode); + mode = mode_for_vector (SImode, n_bits / 4).require (); + inner_mode = mode_for_vector (SImode, n_bits / 8).require (); ops[0] = gen_lowpart (inner_mode, ops[0]); ops[1] = gen_lowpart (inner_mode, ops[1]); subtarget = gen_reg_rtx (mode); @@ -51619,7 +51616,7 @@ ix86_get_mask_mode (unsigned nunits, uns gcc_assert (elem_size * nunits == vector_size); - return mode_for_vector (elem_mode, nunits); + return mode_for_vector (elem_mode, nunits).else_blk (); } Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-09-04 12:18:53.148287319 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-09-04 12:18:55.812299689 +0100 @@ -38679,7 +38679,7 @@ rs6000_expand_vec_perm_const_1 (rtx targ vmode = GET_MODE (target); gcc_assert (GET_MODE_NUNITS (vmode) == 2); - dmode = mode_for_vector (GET_MODE_INNER (vmode), 4); + dmode = mode_for_vector (GET_MODE_INNER (vmode), 4).require (); x = gen_rtx_VEC_CONCAT (dmode, op0, op1); v = gen_rtvec (2, GEN_INT (perm0), GEN_INT (perm1)); x = gen_rtx_VEC_SELECT (vmode, x, gen_rtx_PARALLEL (VOIDmode, v)); Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-09-04 12:18:53.151298637 +0100 +++ gcc/config/rs6000/rs6000.c 2017-09-04 12:18:55.815311006 +0100 @@ -35525,7 +35525,7 @@ rs6000_expand_vec_perm_const_1 (rtx targ vmode = GET_MODE (target); gcc_assert (GET_MODE_NUNITS (vmode) == 2); - dmode = mode_for_vector (GET_MODE_INNER (vmode), 4); + dmode = mode_for_vector (GET_MODE_INNER (vmode), 4).require (); x = gen_rtx_VEC_CONCAT (dmode, op0, op1); v = gen_rtvec (2, GEN_INT (perm0), GEN_INT (perm1)); x = gen_rtx_VEC_SELECT (vmode, x, gen_rtx_PARALLEL (VOIDmode, v)); Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-09-04 12:18:50.673054653 +0100 +++ gcc/expmed.c 2017-09-04 12:18:55.817318551 +0100 @@ -1578,10 +1578,11 @@ extract_bit_field_1 (rtx str_rtx, unsign machine_mode new_mode = GET_MODE (op0); if (GET_MODE_INNER (new_mode) != GET_MODE_INNER (tmode)) { - new_mode = mode_for_vector (GET_MODE_INNER (tmode), - GET_MODE_BITSIZE (GET_MODE (op0)) - / GET_MODE_UNIT_BITSIZE (tmode)); - if (!VECTOR_MODE_P (new_mode) + scalar_mode inner_mode = GET_MODE_INNER (tmode); + unsigned int nunits = (GET_MODE_BITSIZE (GET_MODE (op0)) + / GET_MODE_UNIT_BITSIZE (tmode)); + if (!mode_for_vector (inner_mode, nunits).exists (&new_mode) + || !VECTOR_MODE_P (new_mode) || GET_MODE_SIZE (new_mode) != GET_MODE_SIZE (GET_MODE (op0)) || GET_MODE_INNER (new_mode) != GET_MODE_INNER (tmode) || !targetm.vector_mode_supported_p (new_mode)) Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-09-04 12:18:44.938520082 +0100 +++ gcc/expr.c 2017-09-04 12:18:55.820329869 +0100 @@ -9445,7 +9445,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b tree sel_type = TREE_TYPE (treeop2); machine_mode vmode = mode_for_vector (SCALAR_TYPE_MODE (TREE_TYPE (sel_type)), - TYPE_VECTOR_SUBPARTS (sel_type)); + TYPE_VECTOR_SUBPARTS (sel_type)).require (); gcc_assert (GET_MODE_CLASS (vmode) == MODE_VECTOR_INT); op2 = simplify_subreg (vmode, op2, TYPE_MODE (sel_type), 0); gcc_assert (op2 && GET_CODE (op2) == CONST_VECTOR); Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-08-30 12:20:31.700622400 +0100 +++ gcc/optabs-query.c 2017-09-04 12:18:55.821333642 +0100 @@ -376,10 +376,9 @@ can_vec_perm_p (machine_mode mode, bool return true; /* We allow fallback to a QI vector mode, and adjust the mask. */ - if (GET_MODE_INNER (mode) == QImode) - return false; - qimode = mode_for_vector (QImode, GET_MODE_SIZE (mode)); - if (!VECTOR_MODE_P (qimode)) + if (GET_MODE_INNER (mode) == QImode + || !mode_for_vector (QImode, GET_MODE_SIZE (mode)).exists (&qimode) + || !VECTOR_MODE_P (qimode)) return false; /* ??? For completeness, we ought to check the QImode version of @@ -547,12 +546,14 @@ can_vec_mask_load_store_p (machine_mode vector_sizes &= ~cur; if (cur <= GET_MODE_SIZE (smode)) continue; - vmode = mode_for_vector (smode, cur / GET_MODE_SIZE (smode)); - mask_mode = targetm.vectorize.get_mask_mode (GET_MODE_NUNITS (vmode), - cur); - if (VECTOR_MODE_P (vmode) - && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) - return true; + unsigned int nunits = cur / GET_MODE_SIZE (smode); + if (mode_for_vector (smode, nunits).exists (&vmode) + && VECTOR_MODE_P (vmode)) + { + mask_mode = targetm.vectorize.get_mask_mode (nunits, cur); + if (convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) + return true; + } } return false; } Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-09-04 11:48:08.609549644 +0100 +++ gcc/optabs.c 2017-09-04 12:18:55.823341187 +0100 @@ -5434,13 +5434,10 @@ expand_vec_perm (machine_mode mode, rtx /* Set QIMODE to a different vector mode with byte elements. If no such mode, or if MODE already has byte elements, use VOIDmode. */ - qimode = VOIDmode; - if (GET_MODE_INNER (mode) != QImode) - { - qimode = mode_for_vector (QImode, w); - if (!VECTOR_MODE_P (qimode)) - qimode = VOIDmode; - } + if (GET_MODE_INNER (mode) == QImode + || !mode_for_vector (QImode, w).exists (&qimode) + || !VECTOR_MODE_P (qimode)) + qimode = VOIDmode; /* If the input is a constant, expand it specially. */ gcc_assert (GET_MODE_CLASS (GET_MODE (sel)) == MODE_VECTOR_INT); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-09-04 11:50:24.568774867 +0100 +++ gcc/targhooks.c 2017-09-04 12:18:55.825348732 +0100 @@ -1210,8 +1210,8 @@ default_get_mask_mode (unsigned nunits, gcc_assert (elem_size * nunits == vector_size); - vector_mode = mode_for_vector (elem_mode, nunits); - if (!VECTOR_MODE_P (vector_mode) + if (!mode_for_vector (elem_mode, nunits).exists (&vector_mode) + || !VECTOR_MODE_P (vector_mode) || !targetm.vector_mode_supported_p (vector_mode)) vector_mode = BLKmode; Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-08-31 07:32:43.676061469 +0100 +++ gcc/tree-vect-stmts.c 2017-09-04 12:18:55.828360049 +0100 @@ -6032,8 +6032,9 @@ vectorizable_store (gimple *stmt, gimple /* First check if vec_extract optab doesn't support extraction of vector elts directly. */ scalar_mode elmode = SCALAR_TYPE_MODE (elem_type); - machine_mode vmode = mode_for_vector (elmode, group_size); - if (! VECTOR_MODE_P (vmode) + machine_mode vmode; + if (!mode_for_vector (elmode, group_size).exists (&vmode) + || !VECTOR_MODE_P (vmode) || (convert_optab_handler (vec_extract_optab, TYPE_MODE (vectype), vmode) == CODE_FOR_nothing)) @@ -6046,11 +6047,12 @@ vectorizable_store (gimple *stmt, gimple unsigned lsize = group_size * GET_MODE_BITSIZE (elmode); elmode = int_mode_for_size (lsize, 0).require (); - vmode = mode_for_vector (elmode, nunits / group_size); /* If we can't construct such a vector fall back to element extracts from the original vector type and element size stores. */ - if (VECTOR_MODE_P (vmode) + if (mode_for_vector (elmode, + nunits / group_size).exists (&vmode) + && VECTOR_MODE_P (vmode) && (convert_optab_handler (vec_extract_optab, vmode, elmode) != CODE_FOR_nothing)) @@ -7070,8 +7072,9 @@ vectorizable_load (gimple *stmt, gimple_ /* First check if vec_init optab supports construction from vector elts directly. */ scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vectype)); - machine_mode vmode = mode_for_vector (elmode, group_size); - if (VECTOR_MODE_P (vmode) + machine_mode vmode; + if (mode_for_vector (elmode, group_size).exists (&vmode) + && VECTOR_MODE_P (vmode) && (convert_optab_handler (vec_init_optab, TYPE_MODE (vectype), vmode) != CODE_FOR_nothing)) @@ -7092,10 +7095,11 @@ vectorizable_load (gimple *stmt, gimple_ unsigned lsize = group_size * TYPE_PRECISION (TREE_TYPE (vectype)); elmode = int_mode_for_size (lsize, 0).require (); - vmode = mode_for_vector (elmode, nunits / group_size); /* If we can't construct such a vector fall back to element loads of the original vector type. */ - if (VECTOR_MODE_P (vmode) + if (mode_for_vector (elmode, + nunits / group_size).exists (&vmode) + && VECTOR_MODE_P (vmode) && (convert_optab_handler (vec_init_optab, vmode, elmode) != CODE_FOR_nothing)) { @@ -9098,8 +9102,8 @@ get_vectype_for_scalar_type_and_size (tr lookup a vector mode of the specified size. */ if (size == 0) simd_mode = targetm.vectorize.preferred_simd_mode (inner_mode); - else - simd_mode = mode_for_vector (inner_mode, size / nbytes); + else if (!mode_for_vector (inner_mode, size / nbytes).exists (&simd_mode)) + return NULL_TREE; nunits = GET_MODE_SIZE (simd_mode) / nbytes; /* NOTE: nunits == 1 is allowed to support single element vector types. */ if (nunits < 1)