From patchwork Mon Sep 4 11:41: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: 111547 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp4118567ybm; Mon, 4 Sep 2017 04:41:47 -0700 (PDT) X-Received: by 10.101.80.75 with SMTP id k11mr203546pgo.18.1504525307792; Mon, 04 Sep 2017 04:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504525307; cv=none; d=google.com; s=arc-20160816; b=FRrV0ZeQ6h3a1VRKJG+SPqOIJom+wLVVVl6tEOjMW5H/T/4x9BYLdn3/mmuhoCghSX ljrk42fPJjFsU5RgB6WCLc8nZ4COUy+bBlmgvtV+aHVKJKV+V0xMvVQ+QwrZxmmN9Kmj h5+x7q1T7VmMTP8pO6YJcogq3JJxx030RAMk9fpgdxABY/rFF3NkkAS4g7yLS9Kd7g2A rvjDZOid9vs1ojDalzS2dTSjT8GzqASnXQSQKTasOmo1X9K6kdDWxTnYMi2CFwD+8I8a +CkGjVQyRq7hL7ff4hmHPM20NFSzPU0/Khid4jmehS0+rkLM4KRbQ7boCx6BHVlmpMS2 TdSA== 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=qvXOcPiN3Ecm6wEzcxsc9zn28tUaKKqCQKwG5as16C8=; b=TXweOuwM/M8MF/QyWkZsEd/5OQ6iPu9QP7mmIeCnwa6i7O5j1HM4Ym5Yug3Es0FIZx bUqugst82LAMfICji1bx3tANbEyz+XyHrCkE6KrM2528MgkMsHFGePGuSweyNqrFk9Ou 15WMSGZPu6UeDtmIveIo9H7dqTBfWuGYKMXBCzYE+JxCrupurLjYsGYgwPO/UMyf8yGQ 4/3mwsZG9cUZpAvyhbGpmhCUW4xj5crkKDlveagNTqNoPnJWc0cSku9ru01IPVOQ9YEp /CDo0jmLjpTUQzT8OJpNZuMIWmA1hx+qkg6hPA/T8eB7rSbCu5UI76TimfGnRIOnATFO nTCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=W5v/KYy/; spf=pass (google.com: domain of gcc-patches-return-461410-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461410-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 g3si4810796pfm.132.2017.09.04.04.41.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Sep 2017 04:41:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-461410-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=W5v/KYy/; spf=pass (google.com: domain of gcc-patches-return-461410-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461410-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=f3sgJw7Ix9wT8pHZiSGv6FO8TN6xU 6EeBOmO/UpFtD5Xan4Tq4MK/8aI5cnRtEPiIvSrymOl7B3ynEKOeeqeeyiN33Jow KowSnzV8lD8LgFS+iu2Y5gnkLX7qbhnNZhhCUehQTAl5g70Dn3aG6xKudps92iG/ TqEq5gOStDVXdw= 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=Pjsef8I1ZtdI+mMpRvYnNJqCMc4=; b=W5v /KYy/QU+5xyudaZjxIQgQFhl+FopGmmcSjx3D1I9D5Tq4escORihE7K8LYUwDRlp wI9ffwO6hGhOh/pft8+0d626NkpC5CEiw7nL2Lau7SU5hHS63EOaG58hxPCMevEY r5hc3PxsRjqIHtSFSRCfgEo+hhtKj7PAj/p5lRHA= Received: (qmail 19813 invoked by alias); 4 Sep 2017 11:41:34 -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 18885 invoked by uid 89); 4 Sep 2017 11:41:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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=U** X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Sep 2017 11:41:28 +0000 Received: by mail-wr0-f173.google.com with SMTP id 108so769565wra.5 for ; Mon, 04 Sep 2017 04:41:27 -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=qvXOcPiN3Ecm6wEzcxsc9zn28tUaKKqCQKwG5as16C8=; b=OQs9wi3t7uo/3P6Zrw0i9MaJUEOmk+Lc9HIOSh8AIyUpXC9On+w0gGTCix4RV7kJVF uOxk75/iNzbm3+qn+lPTAttI2b9ECUBIguOeCsu458Wkg7H56lsnodSUpKitVP1wvga+ MyzDvO2otNYUfETx3EjnXl0MwAgU6e/ez+rSdyYwfqVljsJRebVHJY6Miqfd/T9LbBVp DCXhvJ6NWuwH1jazFKUn7O23v1Rq0oLIeNWjQN/ZpflqJDoGZvTB9DBYW7/mNT4Slbdu N9EVYzcm+trvSzWE5n0krEw/PU7Zs8t0WydwkL2p8QSEp2loAw+nQkELQCW35+ECWo99 ZaXg== X-Gm-Message-State: AHPjjUhQKlOGG0Y08VO8xEfQTgWVawZV1erVIT4uoc+9EXp+JE/7TEwe 3h7o/LjpFO3CgVszQKI+CA== X-Google-Smtp-Source: ADKCNb63tx/k2SZNNea9igyW2reZbE4+8rlTbJEB1fRShg5mCG59FAfR4A2eAlCHZwYw69Fq8DgVGw== X-Received: by 10.223.134.174 with SMTP id 43mr105995wrx.173.1504525285989; Mon, 04 Sep 2017 04:41:25 -0700 (PDT) Received: from localhost (94.197.120.41.threembb.co.uk. [94.197.120.41]) by smtp.gmail.com with ESMTPSA id t12sm5384599wra.20.2017.09.04.04.41.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Sep 2017 04:41:25 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [7/9] Make targetm.get_mask_mode return an opt_mode References: <87tw0iiu51.fsf@linaro.org> Date: Mon, 04 Sep 2017 12:41:22 +0100 In-Reply-To: <87tw0iiu51.fsf@linaro.org> (Richard Sandiford's message of "Mon, 04 Sep 2017 12:24:26 +0100") Message-ID: <87y3puhesd.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 ...for consistency with mode_for_vector. 2017-09-04 Richard Sandiford gcc/ * target.def (get_mask_mode): Change return type to opt_mode. Expand commentary. * doc/tm.texi: Regenerate. * targhooks.h (default_get_mask_mode): Return an opt_mode. * targhooks.c (default_get_mask_mode): Likewise. * config/i386/i386.c (ix86_get_mask_mode): Likewise. * optabs-query.c (can_vec_mask_load_store_p): Update use of targetm.get_mask_mode. * tree.c (build_truth_vector_type): Likewise. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-09-04 11:50:24.568774867 +0100 +++ gcc/target.def 2017-09-04 12:18:58.594757220 +0100 @@ -1877,10 +1877,16 @@ The default is zero which means to not i /* Function to get a target mode for a vector mask. */ DEFHOOK (get_mask_mode, - "This hook returns mode to be used for a mask to be used for a vector\n\ -of specified @var{length} with @var{nunits} elements. By default an integer\n\ -vector mode of a proper size is returned.", - machine_mode, + "A vector mask is a value that holds one boolean result for every element\n\ +in a vector. This hook returns the machine mode that should be used to\n\ +represent such a mask when the vector in question is @var{length} bytes\n\ +long and contains @var{nunits} elements. The hook returns an empty\n\ +@code{opt_machine_mode} if no such mode exists.\n\ +\n\ +The default implementation returns the mode of an integer vector that\n\ +is @var{length} bytes long and that contains @var{nunits} elements,\n\ +if such a mode exists.", + opt_machine_mode, (unsigned nunits, unsigned length), default_get_mask_mode) Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-09-04 11:50:24.566073698 +0100 +++ gcc/doc/tm.texi 2017-09-04 12:18:58.593753447 +0100 @@ -5820,10 +5820,16 @@ mode returned by @code{TARGET_VECTORIZE_ The default is zero which means to not iterate over other vector sizes. @end deftypefn -@deftypefn {Target Hook} machine_mode TARGET_VECTORIZE_GET_MASK_MODE (unsigned @var{nunits}, unsigned @var{length}) -This hook returns mode to be used for a mask to be used for a vector -of specified @var{length} with @var{nunits} elements. By default an integer -vector mode of a proper size is returned. +@deftypefn {Target Hook} opt_machine_mode TARGET_VECTORIZE_GET_MASK_MODE (unsigned @var{nunits}, unsigned @var{length}) +A vector mask is a value that holds one boolean result for every element +in a vector. This hook returns the machine mode that should be used to +represent such a mask when the vector in question is @var{length} bytes +long and contains @var{nunits} elements. The hook returns an empty +@code{opt_machine_mode} if no such mode exists. + +The default implementation returns the mode of an integer vector that +is @var{length} bytes long and that contains @var{nunits} elements, +if such a mode exists. @end deftypefn @deftypefn {Target Hook} {void *} TARGET_VECTORIZE_INIT_COST (struct loop *@var{loop_info}) Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-09-04 11:50:24.568774867 +0100 +++ gcc/targhooks.h 2017-09-04 12:18:58.594757220 +0100 @@ -102,7 +102,7 @@ default_builtin_support_vector_misalignm int, bool); extern machine_mode default_preferred_simd_mode (scalar_mode mode); extern unsigned int default_autovectorize_vector_sizes (void); -extern machine_mode default_get_mask_mode (unsigned, unsigned); +extern opt_machine_mode default_get_mask_mode (unsigned, unsigned); extern void *default_init_cost (struct loop *); extern unsigned default_add_stmt_cost (void *, int, enum vect_cost_for_stmt, struct _stmt_vec_info *, int, Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-09-04 12:18:55.825348732 +0100 +++ gcc/targhooks.c 2017-09-04 12:18:58.594757220 +0100 @@ -1200,7 +1200,7 @@ default_autovectorize_vector_sizes (void /* By defaults a vector of integers is used as a mask. */ -machine_mode +opt_machine_mode default_get_mask_mode (unsigned nunits, unsigned vector_size) { unsigned elem_size = vector_size / nunits; @@ -1210,12 +1210,12 @@ default_get_mask_mode (unsigned nunits, gcc_assert (elem_size * nunits == vector_size); - 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; + if (mode_for_vector (elem_mode, nunits).exists (&vector_mode) + && VECTOR_MODE_P (vector_mode) + && targetm.vector_mode_supported_p (vector_mode)) + return vector_mode; - return vector_mode; + return opt_machine_mode (); } /* By default, the cost model accumulates three separate costs (prologue, Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-09-04 12:18:55.808284598 +0100 +++ gcc/config/i386/i386.c 2017-09-04 12:18:58.592749675 +0100 @@ -51598,7 +51598,7 @@ ix86_autovectorize_vector_sizes (void) /* Implemenation of targetm.vectorize.get_mask_mode. */ -static machine_mode +static opt_machine_mode ix86_get_mask_mode (unsigned nunits, unsigned vector_size) { unsigned elem_size = vector_size / nunits; @@ -51616,7 +51616,7 @@ ix86_get_mask_mode (unsigned nunits, uns gcc_assert (elem_size * nunits == vector_size); - return mode_for_vector (elem_mode, nunits).else_blk (); + return mode_for_vector (elem_mode, nunits); } Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-09-04 12:18:55.821333642 +0100 +++ gcc/optabs-query.c 2017-09-04 12:18:58.593753447 +0100 @@ -531,12 +531,9 @@ can_vec_mask_load_store_p (machine_mode if (!VECTOR_MODE_P (vmode)) return false; - mask_mode = targetm.vectorize.get_mask_mode (GET_MODE_NUNITS (vmode), - GET_MODE_SIZE (vmode)); - if (mask_mode == VOIDmode) - return false; - - if (convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) + if ((targetm.vectorize.get_mask_mode + (GET_MODE_NUNITS (vmode), GET_MODE_SIZE (vmode)).exists (&mask_mode)) + && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) return true; vector_sizes = targetm.vectorize.autovectorize_vector_sizes (); @@ -548,12 +545,10 @@ can_vec_mask_load_store_p (machine_mode continue; 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; - } + && VECTOR_MODE_P (vmode) + && targetm.vectorize.get_mask_mode (nunits, cur).exists (&mask_mode) + && convert_optab_handler (op, vmode, mask_mode) != CODE_FOR_nothing) + return true; } return false; } Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-08-30 12:19:19.721220029 +0100 +++ gcc/tree.c 2017-09-04 12:18:58.595760992 +0100 @@ -10243,10 +10243,8 @@ build_vector_type (tree innertype, int n tree build_truth_vector_type (unsigned nunits, unsigned vector_size) { - machine_mode mask_mode = targetm.vectorize.get_mask_mode (nunits, - vector_size); - - gcc_assert (mask_mode != VOIDmode); + machine_mode mask_mode + = targetm.vectorize.get_mask_mode (nunits, vector_size).else_blk (); unsigned HOST_WIDE_INT vsize; if (mask_mode == BLKmode)