This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH], PR target/82015, add PowerPC warning for unpack_vector_int128 with illegal 2nd argument


On Mon, Aug 28, 2017 at 11:41:47PM -0400, Michael Meissner wrote:
> One of the local programmers tried to use the __builtin_unpack_vector_int128
> function, but his second argument was not the constant 0 or 1.  The compiler
> put the 2nd argument into a register, but there wasn't a valid insn for this,
> and raised an insn not found message.  GCC should warn about this illegal
> usage.

Error, not warn (all the code is correct though).

> 	* config/rs6000/rs6000.c (rs6000_expand_binop_builtin): Insure
> 	that the second argument of the built-in functions to unpack
> 	128-bit scalar types to 64-bit values is 0 or 1.  Change to use a
> 	switch statement instead a lot of if statements.

It usually is easier to review if you post the big mechanical changes
as a separate patch.  But I'll manage, this one isn't so bad :-)

> @@ -14050,6 +14051,21 @@ rs6000_expand_binop_builtin (enum insn_c
>  	  error ("argument 2 must be a 7-bit unsigned literal");
>  	  return CONST0_RTX (tmode);
>  	}
> +      break;
> +    case CODE_FOR_unpackv1ti:
> +    case CODE_FOR_unpackkf:
> +    case CODE_FOR_unpacktf:
> +    case CODE_FOR_unpackif:
> +    case CODE_FOR_unpacktd:
> +      /* Only allow 1-bit unsigned literals. */
> +      STRIP_NOPS (arg1);
> +      if (TREE_CODE (arg1) != INTEGER_CST
> +	  || !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, 1))
> +	{
> +	  error ("argument 2 must be 0 or 1");
> +	  return CONST0_RTX (tmode);
> +	}
> +      break;

This loses that it must be a literal, compared to the 5/6/7 bit messages.
Maybe just say "1-bit unsigned literal", it reads a little bit funny, but
at least it is correct (for some meaning of "literal", anyway) ;-)

Okay for trunk; okay for the release branches with the obvious changes.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]