From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 11:41:00 -0000 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 Content-Type: text/plain X-SW-Source: 2017-09/txt/msg00172.txt.bz2 ...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)