public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Fixbug for fsflags instruction error using immediate.
@ 2023-07-25  6:39 Jin Ma
  2023-07-25  6:48 ` Robin Dapp
  2023-07-25  7:28 ` [PATCH v2] " Jin Ma
  0 siblings, 2 replies; 18+ messages in thread
From: Jin Ma @ 2023-07-25  6:39 UTC (permalink / raw)
  To: gcc-patches
  Cc: jeffreyalaw, palmer, richard.sandiford, kito.cheng,
	christoph.muellner, jinma.contrib, Jin Ma

The pattern mistakenly believes that fsflags can use immediate numbers,
but in fact it does not support it. Immediate numbers should use fsflagsi.

For example:
__builtin_riscv_fsflags(4);

The following error occurred:
/tmp/ccoWdWqT.s: Assembler messages:
/tmp/ccoWdWqT.s:14: Error: illegal operands `fsflags 4'

gcc/ChangeLog:

	* config/riscv/riscv.md: Likewise.
---
 gcc/config/riscv/riscv.md | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 4615e811947..1ec85e30d7e 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -3074,7 +3074,7 @@ (define_insn "riscv_frcsr"
   "frcsr\t%0")
 
 (define_insn "riscv_fscsr"
-  [(unspec_volatile [(match_operand:SI 0 "csr_operand" "rK")] UNSPECV_FSCSR)]
+  [(unspec_volatile [(match_operand:SI 0 "csr_operand" "r")] UNSPECV_FSCSR)]
   "TARGET_HARD_FLOAT || TARGET_ZFINX"
   "fscsr\t%0")
 
@@ -3085,9 +3085,11 @@ (define_insn "riscv_frflags"
   "frflags\t%0")
 
 (define_insn "riscv_fsflags"
-  [(unspec_volatile [(match_operand:SI 0 "csr_operand" "rK")] UNSPECV_FSFLAGS)]
+  [(unspec_volatile [(match_operand:SI 0 "csr_operand" "r,K")] UNSPECV_FSFLAGS)]
   "TARGET_HARD_FLOAT || TARGET_ZFINX"
-  "fsflags\t%0")
+  "@
+   fsflags\t%0
+   fsflagsi\t%0")
 
 (define_insn "*riscv_fsnvsnan<mode>2"
   [(unspec_volatile [(match_operand:ANYF 0 "register_operand" "f")
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-07-26  8:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-25  6:39 [PATCH] RISC-V: Fixbug for fsflags instruction error using immediate Jin Ma
2023-07-25  6:48 ` Robin Dapp
2023-07-25  7:32   ` Jin Ma
2023-07-25  7:28 ` [PATCH v2] " Jin Ma
2023-07-25 11:00   ` Kito Cheng
2023-07-26  2:17     ` [PATCH v3] " Jin Ma
2023-07-26  2:30       ` juzhe.zhong
2023-07-26  3:33         ` Jin Ma
2023-07-26  3:41           ` juzhe.zhong
2023-07-26  3:45             ` Kito Cheng
2023-07-26  3:49               ` juzhe.zhong
2023-07-26  5:36                 ` Jin Ma
2023-07-26  5:41         ` [PATCH v4] " Jin Ma
2023-07-26  6:04           ` juzhe.zhong
2023-07-26  7:07           ` Kito Cheng
2023-07-26  7:19             ` juzhe.zhong
2023-07-26  7:39               ` Kito Cheng
2023-07-26  8:22                 ` Kito Cheng

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).