public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2775] RISC-V: Fixbug for fsflags instruction error using immediate.
@ 2023-07-26  8:21 Kito Cheng
  0 siblings, 0 replies; only message in thread
From: Kito Cheng @ 2023-07-26  8:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ad0dde0af107aaf6a91e37f3aa31249e34df6ce0

commit r14-2775-gad0dde0af107aaf6a91e37f3aa31249e34df6ce0
Author: Jin Ma <jinma@linux.alibaba.com>
Date:   Wed Jul 26 13:41:04 2023 +0800

    RISC-V: Fixbug for fsflags instruction error using immediate.
    
    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/testsuite/ChangeLog:
    
            * gcc.target/riscv/fsflags.c: New test.

Diff:
---
 gcc/config/riscv/riscv.md                |  4 ++--
 gcc/testsuite/gcc.target/riscv/fsflags.c | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 4615e811947..24515bcf706 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -3074,7 +3074,7 @@
   "frcsr\t%0")
 
 (define_insn "riscv_fscsr"
-  [(unspec_volatile [(match_operand:SI 0 "csr_operand" "rK")] UNSPECV_FSCSR)]
+  [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] UNSPECV_FSCSR)]
   "TARGET_HARD_FLOAT || TARGET_ZFINX"
   "fscsr\t%0")
 
@@ -3087,7 +3087,7 @@
 (define_insn "riscv_fsflags"
   [(unspec_volatile [(match_operand:SI 0 "csr_operand" "rK")] UNSPECV_FSFLAGS)]
   "TARGET_HARD_FLOAT || TARGET_ZFINX"
-  "fsflags\t%0")
+  "fsflags%i0\t%0")
 
 (define_insn "*riscv_fsnvsnan<mode>2"
   [(unspec_volatile [(match_operand:ANYF 0 "register_operand" "f")
diff --git a/gcc/testsuite/gcc.target/riscv/fsflags.c b/gcc/testsuite/gcc.target/riscv/fsflags.c
new file mode 100644
index 00000000000..74a97b8a7c7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/fsflags.c
@@ -0,0 +1,16 @@
+/* Verify that fsflags is using the correct register or immediate.  */
+/* { dg-do compile } */
+/* { dg-require-effective-target hard_float } */
+/* { dg-options "-O" } */
+
+void foo1 (int a)
+{
+   __builtin_riscv_fsflags(a);
+}
+void foo2 ()
+{
+   __builtin_riscv_fsflags(4);
+}
+
+/* { dg-final { scan-assembler-times "fsflags\t" 1 } } */
+/* { dg-final { scan-assembler-times "fsflagsi\t" 1 } } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-26  8:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26  8:21 [gcc r14-2775] RISC-V: Fixbug for fsflags instruction error using immediate 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).