diff options
author | Jin Ma <jinma@linux.alibaba.com> | 2023-07-26 13:41:04 +0800 |
---|---|---|
committer | Kito Cheng <kito.cheng@sifive.com> | 2023-07-26 15:40:26 +0800 |
commit | ad0dde0af107aaf6a91e37f3aa31249e34df6ce0 (patch) | |
tree | 8af3e3be0164ee4f653da98fc5998a3f26b1638d /gcc | |
parent | 645c67f80c6258c1f54ec567f604008adbdb8a04 (diff) | |
download | gcc-ad0dde0af107aaf6a91e37f3aa31249e34df6ce0.zip gcc-ad0dde0af107aaf6a91e37f3aa31249e34df6ce0.tar.gz gcc-ad0dde0af107aaf6a91e37f3aa31249e34df6ce0.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/riscv/riscv.md | 4 | ||||
-rw-r--r-- | 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 4615e81..24515bc 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 0000000..74a97b8 --- /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 } } */ |