public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Ilya Enkovich <enkovich.gnu@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH, vec-tails 04/10] Add masking cost
Date: Thu, 16 Jun 2016 06:17:00 -0000	[thread overview]
Message-ID: <9259cabd-b505-679a-8345-1496c7e11b27@redhat.com> (raw)
In-Reply-To: <20160519194036.GE40563@msticlxl57.ims.intel.com>

On 05/19/2016 01:40 PM, Ilya Enkovich wrote:
> Hi,
>
> This patch extends vectorizer cost model to include masking cost by
> adding new cost model locations and new target hook to compute
> masking cost.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2016-05-19  Ilya Enkovich  <ilya.enkovich@intel.com>
>
> 	* config/i386/i386.c (ix86_init_cost): Extend costs array.
> 	(ix86_add_stmt_masking_cost): New.
> 	(ix86_finish_cost): Add masking_prologue_cost and masking_body_cost
> 	args.
> 	(TARGET_VECTORIZE_ADD_STMT_MASKING_COST): New.
> 	* config/i386/i386.h (TARGET_INCREASE_MASK_STORE_COST): New.
> 	* config/i386/x86-tune.def (X86_TUNE_INCREASE_MASK_STORE_COST): New.
> 	* config/rs6000/rs6000.c (_rs6000_cost_data): Extend cost array.
> 	(rs6000_init_cost): Initialize new cost elements.
> 	(rs6000_finish_cost): Add masking_prologue_cost and masking_body_cost.
> 	* config/spu/spu.c (spu_init_cost): Extend costs array.
> 	(spu_finish_cost): Add masking_prologue_cost and masking_body_cost args.
> 	* doc/tm.texi.in (TARGET_VECTORIZE_ADD_STMT_MASKING_COST): New.
> 	* doc/tm.texi: Regenerated.
> 	* target.def (add_stmt_masking_cost): New.
> 	(finish_cost): Add masking_prologue_cost and masking_body_cost args.
> 	* target.h (enum vect_cost_for_stmt): Add vector_mask_load and
> 	vector_mask_store.
> 	(enum vect_cost_model_location): Add vect_masking_prologue
> 	and vect_masking_body.
> 	* targhooks.c (default_builtin_vectorization_cost): Support
> 	vector_mask_load and vector_mask_store.
> 	(default_init_cost): Extend costs array.
> 	(default_add_stmt_masking_cost): New.
> 	(default_finish_cost): Add masking_prologue_cost and masking_body_cost
> 	args.
> 	* targhooks.h (default_add_stmt_masking_cost): New.
> 	* tree-vect-loop.c (vect_estimate_min_profitable_iters): Adjust
> 	finish_cost call.
> 	* tree-vect-slp.c (vect_bb_vectorization_profitable_p): Likewise.
> 	* tree-vectorizer.h (add_stmt_masking_cost): New.
> 	(finish_cost): Add masking_prologue_cost and masking_body_cost args.
>
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 9f62089..6c2c364 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -53932,8 +53932,12 @@ ix86_spill_class (reg_class_t rclass, machine_mode mode)
>  static void *
>  ix86_init_cost (struct loop *)
>  {
> -  unsigned *cost = XNEWVEC (unsigned, 3);
> -  cost[vect_prologue] = cost[vect_body] = cost[vect_epilogue] = 0;
> +  unsigned *cost = XNEWVEC (unsigned, 5);
> +  cost[vect_prologue] = 0;
> +  cost[vect_body]     = 0;
> +  cost[vect_epilogue] = 0;
> +  cost[vect_masking_prologue] = 0;
> +  cost[vect_masking_body] = 0;
>    return cost;
Trivial nit -- no need or desire to use whitespace to line up the 
initializers.   It looks like others may have done this in the 
duplicated instances of finish_cost. But we shouldn't propagate that 
mistake into the init_cost hooks ;-)


@@ -1115,8 +1117,12 @@ default_get_mask_mode (unsigned nunits, unsigned 
vector_size)
>  void *
>  default_init_cost (struct loop *loop_info ATTRIBUTE_UNUSED)
>  {
> -  unsigned *cost = XNEWVEC (unsigned, 3);
> -  cost[vect_prologue] = cost[vect_body] = cost[vect_epilogue] = 0;
> +  unsigned *cost = XNEWVEC (unsigned, 5);
> +  cost[vect_prologue] = 0;
> +  cost[vect_body]     = 0;
> +  cost[vect_epilogue] = 0;
> +  cost[vect_masking_prologue] = 0;
> +  cost[vect_masking_body] = 0;
>    return cost;
Here too.  There's others.  I won't point them all out.  Please double 
check for this nit in any added code.  You don't have to go back and fix 
existing problems of this nature.

I don't see anything here I really object to -- Richi and I may disagree 
on the compute-costs once in a single scan vs restarting the scan.  If 
Richi feels strongly about restarting for some reason, I'll defer to him 
-- he's done more work in the vectorizer than myself.

I'd suggest taking another stab at the docs for the hooks based on 
Richi's question about whether or not the hook returns the cost of hte 
masked statement or the cost of masking the statement.

jeff

  parent reply	other threads:[~2016-06-16  6:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19 19:41 Ilya Enkovich
2016-05-20  9:24 ` Richard Biener
2016-05-20  9:44   ` Ilya Enkovich
2016-05-20 11:15     ` Richard Biener
2016-05-20 11:32       ` Ilya Enkovich
2016-06-16  6:06         ` Jeff Law
2016-06-16  6:17 ` Jeff Law [this message]
2016-06-22 14:16   ` Ilya Enkovich
2016-07-11 13:38     ` Ilya Enkovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9259cabd-b505-679a-8345-1496c7e11b27@redhat.com \
    --to=law@redhat.com \
    --cc=enkovich.gnu@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).