public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: HAO CHEN GUI <guihaoc@linux.ibm.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, David <dje.gcc@gmail.com>,
	"Kewen.Lin" <linkw@linux.ibm.com>,
	Peter Bergner <bergner@linux.ibm.com>
Subject: Re: [PATCH v5, rs6000] Change mode and insn condition for VSX scalar extract/insert instructions
Date: Mon, 12 Dec 2022 10:21:01 -0600	[thread overview]
Message-ID: <20221212162100.GD25951@gate.crashing.org> (raw)
In-Reply-To: <a63fac98-4737-3f8d-44d9-92874ed814d6@linux.ibm.com>

Hi!

On Fri, Dec 02, 2022 at 03:03:46PM +0800, HAO CHEN GUI wrote:
>   For scalar extract/insert instructions, exponent field can be stored in a
> 32-bit register. So this patch changes the mode of exponent field from DI to
> SI so that these instructions can be generated in a 32-bit environment. Also
> it removes TARGET_64BIT check for these instructions.

>   This patch also changes prototypes and catagories of relevant built-ins and
> effective target checks of test cases.

You can not change the types of builtins, unless they were completely
broken before or something serious like that.  Existing user code should
keep doing the same as it did before.  So any change like this needs a
lot more justification.

> --- a/gcc/config/rs6000/rs6000-builtins.def
> +++ b/gcc/config/rs6000/rs6000-builtins.def
> @@ -2833,6 +2833,11 @@
>    const signed int __builtin_dtstsfi_ov_td (const int<6>, _Decimal128);
>      TSTSFI_OV_TD dfptstsfi_unordered_td {}
> 
> +  const unsigned int __builtin_vsx_scalar_extract_exp (double);
> +    VSEEDP xsxexpdp {}
> +
> +  const double __builtin_vsx_scalar_insert_exp_dp (double, unsigned int);
> +    VSIEDPF xsiexpdpf {}

vec_insert_exp etc. are externally documented (in the PVIPR), these
(internal) builtins should behave similarly.

You can change the *internal* stuff fine of course.

> --- a/gcc/config/rs6000/rs6000-overload.def
> +++ b/gcc/config/rs6000/rs6000-overload.def
> @@ -4507,9 +4507,9 @@
>      VSESQP
> 
>  [VEC_VSIE, scalar_insert_exp, __builtin_vec_scalar_insert_exp]
> -  double __builtin_vec_scalar_insert_exp (unsigned long long, unsigned long long);
> +  double __builtin_vec_scalar_insert_exp (unsigned long long, unsigned int);
>      VSIEDP
> -  double __builtin_vec_scalar_insert_exp (double, unsigned long long);
> +  double __builtin_vec_scalar_insert_exp (double, unsigned int);
>      VSIEDPF

NAK on this as well.

>  ;; VSX Scalar Extract Exponent Double-Precision
>  (define_insn "xsxexpdp"
> -  [(set (match_operand:DI 0 "register_operand" "=r")
> -	(unspec:DI [(match_operand:DF 1 "vsx_register_operand" "wa")]
> +  [(set (match_operand:SI 0 "register_operand" "=r")
> +	(unspec:SI [(match_operand:DF 1 "vsx_register_operand" "wa")]
>  	 UNSPEC_VSX_SXEXPDP))]
> -  "TARGET_P9_VECTOR && TARGET_64BIT"
> +  "TARGET_P9_VECTOR"
>    "xsxexpdp %0,%x1"
>    [(set_attr "type" "integer")])

You need to keep a version that returns DImode (where it did before,
64-bit).  But you can use :GPR perhaps?  That also allows :SI on 64-bit,
so things can be optimised to that where it makes sense.

And :SI on 32-bit is just new, no problems there :-)

> @@ -5116,7 +5116,7 @@ (define_insn "xsxsigdp"
>    [(set (match_operand:DI 0 "register_operand" "=r")
>  	(unspec:DI [(match_operand:DF 1 "vsx_register_operand" "wa")]
>  	 UNSPEC_VSX_SXSIG))]
> -  "TARGET_P9_VECTOR && TARGET_64BIT"
> +  "TARGET_P9_VECTOR && TARGET_POWERPC64"

That is a good fix, separate from the rest though, so could you do it
first please?


Segher

      parent reply	other threads:[~2022-12-12 16:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  7:03 HAO CHEN GUI
2022-12-08  8:47 ` Kewen.Lin
2022-12-12  3:23   ` HAO CHEN GUI
2022-12-12 10:23     ` Kewen.Lin
2022-12-12 16:21 ` Segher Boessenkool [this message]

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=20221212162100.GD25951@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guihaoc@linux.ibm.com \
    --cc=linkw@linux.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).