public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "jinma" <jinma@linux.alibaba.com>
To: "gcc-patches" <gcc-patches@gcc.gnu.org>
Cc: "jeffreyalaw" <jeffreyalaw@gmail.com>,
	"kito.cheng" <kito.cheng@sifive.com>,
	"kito.cheng" <kito.cheng@gmail.com>,
	"palmer" <palmer@dabbelt.com>, "ijinma" <ijinma@yeah.net>
Subject: Re: [PATCH v8] RISC-V: Add the 'zfa' extension, version 0.2.
Date: Sat, 06 May 2023 20:53:09 +0800	[thread overview]
Message-ID: <b98f17f7-7bde-4f02-ad2e-d44bfd1c5769.jinma@linux.alibaba.com> (raw)
In-Reply-To: <20230506075440.1078-1-jinma@linux.alibaba.com>

> > > diff --git a/gcc/config/riscv/iterators.md b/gcc/config/riscv/iterators.md
> > > index 9b767038452..c81b08e3cc5 100644
> > > --- a/gcc/config/riscv/iterators.md
> > > +++ b/gcc/config/riscv/iterators.md
> > > @@ -288,3 +288,8 @@ (define_int_iterator QUIET_COMPARISON [UNSPEC_FLT_QUIET UNSPEC_FLE_QUIET])
> > >   (define_int_attr quiet_pattern [(UNSPEC_FLT_QUIET "lt") (UNSPEC_FLE_QUIET "le")])
> > >   (define_int_attr QUIET_PATTERN [(UNSPEC_FLT_QUIET "LT") (UNSPEC_FLE_QUIET "LE")])
> > >   
> > > +(define_int_iterator ROUND [UNSPEC_ROUND UNSPEC_FLOOR UNSPEC_CEIL UNSPEC_BTRUNC UNSPEC_ROUNDEVEN UNSPEC_NEARBYINT])
> > > +(define_int_attr round_pattern [(UNSPEC_ROUND "round") (UNSPEC_FLOOR "floor") (UNSPEC_CEIL "ceil")
> > > +				(UNSPEC_BTRUNC "btrunc") (UNSPEC_ROUNDEVEN "roundeven") (UNSPEC_NEARBYINT "nearbyint")])
> > > +(define_int_attr round_rm [(UNSPEC_ROUND "rmm") (UNSPEC_FLOOR "rdn") (UNSPEC_CEIL "rup")
> > > +			   (UNSPEC_BTRUNC "rtz") (UNSPEC_ROUNDEVEN "rne") (UNSPEC_NEARBYINT "dyn")])
> > Do we really need to use unspecs for all these cases?  I would expect 
> > some correspond to the trunc, round, ceil, nearbyint, etc well known RTX 
> > codes.
> > 
> > In general, we should try to avoid unspecs when there is a clear 
> > semantic match between the instruction and GCC's RTX opcodes.  So please 
> > review the existing RTX code semantics to see if any match the new 
> > instructions.  If there are matches, use those RTX codes rather than 
> > UNSPECs.
> 
> I'll try, thanks.


I encountered some confusion about this. I checked gcc's documents and
found no RTX codes that can correspond to round, ceil, nearbyint, etc.
Only "(fix:m x)" seems to correspond to trunc, which can be expressed
as rounding towards zero, while others have not yet been found.


In addition, I found that other architectures also seem to adopt the
unspecs for all these cases  on the latest master branch.
arm: https://github.com/gcc-mirror/gcc/commit/1dd4fe1fd892458ce29f15f3ca95125a11b2534f#diff-159a39276c509272adfaeef91c2110f54f65c38f7fd1ab2f1e750af0a7f86377R1251
rs6000: https://github.com/gcc-mirror/gcc/commit/7042fe5ef83ff0585eb91144817105f26d566d4c#diff-1a2d4976d867ead4556899cab1dbb39f5069574276e06a2976fb62b771ece2e3R6995
i386: https://github.com/gcc-mirror/gcc/commit/3e8c4b925a9825fdb8c81f47b621f63108894362#diff-f00b14a8846eb6aaeb981077e36ac3668160d7dabb490beeb1f62792afa83281R23332

Can you give me some advice?

> > > @@ -1580,6 +1609,26 @@ (define_insn "l<rint_pattern><ANYF:mode><GPR:mode>2"
> > >     [(set_attr "type" "fcvt")
> > >      (set_attr "mode" "<ANYF:MODE>")])
> > >   
> > > +(define_insn "<round_pattern><ANYF:mode>2"
> > > +  [(set (match_operand:ANYF     0 "register_operand" "=f")
> > > +	(unspec:ANYF
> > > +	    [(match_operand:ANYF 1 "register_operand" " f")]
> > > +	ROUND))]
> > > +  "TARGET_HARD_FLOAT && TARGET_ZFA"
> > > +  "fround.<ANYF:fmt>\t%0,%1,<round_rm>"
> > > +  [(set_attr "type" "fcvt")
> > > +   (set_attr "mode" "<ANYF:MODE>")])
> > > +
> > > +(define_insn "rint<ANYF:mode>2"
> > > +  [(set (match_operand:ANYF     0 "register_operand" "=f")
> > > +	(unspec:ANYF
> > > +	    [(match_operand:ANYF 1 "register_operand" " f")]
> > > +	UNSPEC_RINT))]
> > > +  "TARGET_HARD_FLOAT && TARGET_ZFA"
> > > +  "froundnx.<ANYF:fmt>\t%0,%1"
> > > +  [(set_attr "type" "fcvt")
> > > +   (set_attr "mode" "<ANYF:MODE>")])
> > Please review the existing RTX codes and their semantics in the 
> > internals manual and if any of the new instructions match those existing 
> > primitives, implement them using those RTX codes rather than with an UNSPEC.
> >
> 
> I'll try, thanks.
> 

thanks.

Jin Ma

  reply	other threads:[~2023-05-06 12:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19  9:57 Jin Ma
2023-05-05 15:03 ` Christoph Müllner
2023-05-05 15:04   ` Christoph Müllner
2023-05-05 15:12     ` Palmer Dabbelt
2023-05-05 15:43       ` Christoph Müllner
2023-05-05 23:31 ` Jeff Law
2023-05-06  7:54 ` Jin Ma
2023-05-06 12:53   ` jinma [this message]
2023-05-16  3:59     ` Jeff Law
2023-05-15 13:16 ` [PATCH v9] " Jin Ma
2023-05-15 13:30   ` jinma
2023-05-16  4:00     ` Jeff Law
2023-05-16  4:16   ` Jeff Law
2023-05-16  7:06     ` jinma
2023-05-16  7:53       ` Kito Cheng
2023-08-09 18:11       ` Vineet Gupta
2023-08-11 15:49         ` Jin Ma
2023-08-14  6:00         ` Jin Ma
2023-08-14  6:10           ` Jin Ma
2023-08-14 22:11             ` Jeff Law

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=b98f17f7-7bde-4f02-ad2e-d44bfd1c5769.jinma@linux.alibaba.com \
    --to=jinma@linux.alibaba.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ijinma@yeah.net \
    --cc=jeffreyalaw@gmail.com \
    --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).