[13/n] PR85694: Try to avoid vectorising casts of invariants

Jeff Law law@redhat.com
Sat Jun 23 05:02:00 GMT 2018


On 06/20/2018 04:32 AM, Richard Sandiford wrote:
> vect_recog_rotate_pattern had code to prevent operations
> on invariants being vectorised unnecessarily:
> 
>   if (dt == vect_external_def
>       && TREE_CODE (oprnd1) == SSA_NAME
>       && is_a <loop_vec_info> (vinfo))
>     {
>       struct loop *loop = as_a <loop_vec_info> (vinfo)->loop;
>       ext_def = loop_preheader_edge (loop);
>       if (!SSA_NAME_IS_DEFAULT_DEF (oprnd1))
>         {
>           basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (oprnd1));
>           if (bb == NULL
>               || !dominated_by_p (CDI_DOMINATORS, ext_def->dest, bb))
>             ext_def = NULL;
>         }
>     }
>   [..]
>       if (ext_def)
>         {
>           basic_block new_bb
>             = gsi_insert_on_edge_immediate (ext_def, def_stmt);
>           gcc_assert (!new_bb);
>         }
> 
> This patch reuses the same idea for casts of invariants created
> during widening optimisations.
> 
> One hitch was that vect_loop_versioning asserted that the vector loop
> preheader was still empty, although the cfg transformation it's doing
> should be correct either way.
> 
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> 2018-06-20  Richard Sandiford  <richard.sandiford@arm.com>
> 
> gcc/
> 	* tree-vect-patterns.c (vect_get_external_def_edge): New function,
> 	split out from...
> 	(vect_recog_rotate_pattern): ...here.
> 	(vect_convert_input): Try to insert casts of invariants in the
> 	preheader.
> 	* tree-vect-loop-manip.c (vect_loop_versioning): Don't require the
> 	preheader to be empty.
> 
> gcc/testsuite/
> 	* gcc.dg/vect/vect-widen-mult-extern-1.c: New test.
OK
jeff
igned int *x2, unsigned short *y, unsigned char z)
> +{
> +  unsigned short zu = z;
> +  for (int i = 0; i < N; ++i)
> +    {
> +      unsigned short yi = y[i];
> +      x1[i] = x1[i] > 10 ? yi * zu : x1[i] + 1;
> +      x2[i] += 1;
> +    }
> +}
> 



More information about the Gcc-patches mailing list