This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH], PR target/82015, add PowerPC warning for unpack_vector_int128 with illegal 2nd argument
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Michael Meissner <meissner at linux dot vnet dot ibm dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, David Edelsohn <dje dot gcc at gmail dot com>, Bill Schmidt <wschmidt at linux dot vnet dot ibm dot com>
- Date: Tue, 29 Aug 2017 08:31:38 -0500
- Subject: Re: [PATCH], PR target/82015, add PowerPC warning for unpack_vector_int128 with illegal 2nd argument
- Authentication-results: sourceware.org; auth=none
- References: <20170829034147.GA15563@ibm-tiger.the-meissners.org>
Hi!
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.
Thanks!
Segher