[PATCH, RFC, rs6000, v3] enable early gimple-folding of vec_splat

Bill Schmidt wschmidt@linux.ibm.com
Wed Sep 12 13:47:00 GMT 2018


On 9/12/18 8:23 AM, Segher Boessenkool wrote:
> Hi!
>
> Sorry this is all taking so long.
>
> On Mon, Aug 20, 2018 at 04:44:30PM -0500, Will Schmidt wrote:
>> 2018-08-20  Will Schmidt  <will_schmidt@vnet.ibm.com>
>>     
>>     	* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for
>>     	  early gimple folding of vec_splat().
> "early" should indent together with the "*" above, not "config".
>
>>     	* tree-vect-generic.c: Remove static from tree_vec_extract() definition.
>>     	* gimple-fold.h:  Add an extern define for tree_vec_extract().
> One space after : .
>
>> --- a/gcc/config/rs6000/rs6000.c
>> +++ b/gcc/config/rs6000/rs6000.c
>> @@ -15768,10 +15768,52 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
>>  	 tree splat_tree = build_vector_from_val (TREE_TYPE (lhs), splat_value);
>>  	 g = gimple_build_assign (lhs, splat_tree);
>>  	 gimple_set_location (g, gimple_location (stmt));
>>  	 gsi_replace (gsi, g, true);
>>  	 return true;
>> +	}
> Something is wrong with the indent here (in the original code already).
>
>> +	arg0 = gimple_call_arg (stmt, 0); /* input vector.  */
>> +	arg1 = gimple_call_arg (stmt, 1); /* index into arg0.  */
>> +	/* Only fold the vec_splat_*() if arg1 is both a constant value, and a valid
>> +	 index into the arg0 vector.  */
> First comment line wraps, please break it a little earlier?
>
>> +	unsigned int n_elts = VECTOR_CST_NELTS (arg0);
>> +	if (TREE_CODE (arg1) != INTEGER_CST
>> +	    || TREE_INT_CST_LOW (arg1) > (n_elts -1))
>> +	  return false;
> I think you should check lower bound 0 as well.  Maybe use IN_RANGE?

And "-1" should be "- 1".  Thanks!

Bill

>
> The rest looks fine, thanks!  Okay for trunk (with the trivialities fixed).
>
>
> Segher
>



More information about the Gcc-patches mailing list