public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@embecosm.com>
To: Kito Cheng <kito.cheng@sifive.com>
Cc: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com,
	 Jim Wilson <jim.wilson.gcc@gmail.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	 andrew@sifive.com, juzhe.zhong@rivai.ai,
	joseph@codesourcery.com
Subject: Re: [PATCH v2 1/2] RISC-V: Support _Float16 type.
Date: Mon, 5 Dec 2022 13:05:22 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.20.2212051305120.7841@tpp.orcam.me.uk> (raw)
In-Reply-To: <20220810154456.101086-1-kito.cheng@sifive.com>

Hi Kito,

 I came across this issue while inspecting code and I have been wondering 
what the reason was to downgrade current FMV.X.W and FMW.W.X instructions 
to their older FMV.S.W and FMV.W.S variants here:

On Wed, 10 Aug 2022, Kito Cheng wrote:

> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 5a0adffb5ce..47e6110767c 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -2308,10 +2310,19 @@ riscv_output_move (rtx dest, rtx src)
>    if (dest_code == REG && GP_REG_P (REGNO (dest)))
>      {
>        if (src_code == REG && FP_REG_P (REGNO (src)))
> -	return dbl_p ? "fmv.x.d\t%0,%1" : "fmv.x.w\t%0,%1";
> +	switch (width)
> +	  {
> +	  case 2:
> +	    /* Using fmv.x.s + sign-extend to emulate fmv.x.h.  */
> +	    return "fmv.x.s\t%0,%1;slli\t%0,%0,16;srai\t%0,%0,16";
> +	  case 4:
> +	    return "fmv.x.s\t%0,%1";
> +	  case 8:
> +	    return "fmv.x.d\t%0,%1";
> +	  }

and here:

> @@ -2353,18 +2364,24 @@ riscv_output_move (rtx dest, rtx src)
>  	    return "mv\t%0,%z1";
>  
>  	  if (FP_REG_P (REGNO (dest)))
> -	    {
> -	      if (!dbl_p)
> -		return "fmv.w.x\t%0,%z1";
> -	      if (TARGET_64BIT)
> -		return "fmv.d.x\t%0,%z1";
> -	      /* in RV32, we can emulate fmv.d.x %0, x0 using fcvt.d.w */
> -	      gcc_assert (src == CONST0_RTX (mode));
> -	      return "fcvt.d.w\t%0,x0";
> -	    }
> +	    switch (width)
> +	      {
> +	      case 2:
> +		/* High 16 bits should be all-1, otherwise HW will treated
> +		   as a n-bit canonical NaN, but isn't matter for softfloat.  */
> +		return "fmv.s.x\t%0,%1";
> +	      case 4:
> +		return "fmv.s.x\t%0,%z1";
> +	      case 8:
> +		if (TARGET_64BIT)
> +		  return "fmv.d.x\t%0,%z1";
> +		/* in RV32, we can emulate fmv.d.x %0, x0 using fcvt.d.w */

(Incorrect comment formatting here as well.)

> +		gcc_assert (src == CONST0_RTX (mode));
> +		return "fcvt.d.w\t%0,x0";
> +	      }

Was it intentional or just an oversight in review?  If intentional, I'd 
expect such a change to happen on its own rather than sneaked in with a 
large functional update.

  Maciej

  parent reply	other threads:[~2022-12-05 13:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10 15:44 Kito Cheng
2022-08-10 15:44 ` [PATCH v2 2/2] RISC-V: Support zfh and zfhmin extension Kito Cheng
2022-08-10 23:19   ` 钟居哲
2022-12-05 13:05 ` Maciej W. Rozycki [this message]
2022-12-07 14:15   ` [PATCH v2 1/2] RISC-V: Support _Float16 type Kito Cheng

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=alpine.DEB.2.20.2212051305120.7841@tpp.orcam.me.uk \
    --to=macro@embecosm.com \
    --cc=andrew@sifive.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=juzhe.zhong@rivai.ai \
    --cc=kito.cheng@gmail.com \
    --cc=kito.cheng@sifive.com \
    --cc=palmer@dabbelt.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).