public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Michael Meissner <meissner@linux.vnet.ibm.com>,
	       GCC Patches <gcc-patches@gcc.gnu.org>,
	       David Edelsohn <dje.gcc@gmail.com>,
	       Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Subject: Re: [PATCH], PR target/82015, add PowerPC warning for unpack_vector_int128 with illegal 2nd argument
Date: Tue, 29 Aug 2017 14:13:00 -0000	[thread overview]
Message-ID: <20170829133138.GK13471@gate.crashing.org> (raw)
In-Reply-To: <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

  reply	other threads:[~2017-08-29 13:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29  6:57 Michael Meissner
2017-08-29 14:13 ` Segher Boessenkool [this message]
2017-08-30 19:29   ` Michael Meissner
2017-09-08 19:08 ` Andreas Schwab

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=20170829133138.GK13471@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=meissner@linux.vnet.ibm.com \
    --cc=wschmidt@linux.vnet.ibm.com \
    /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).