Skip to content

Commit cb2daf5

Browse files
Fix PR 106600: __builtin_bswap32 is not hooked up for ZBB for 32bit
The problem here is the bswap<mode>2 pattern had a check for TARGET_64BIT but then used the X iterator. Since the X iterator is either SI or DI depending on the setting TARGET_64BIT, there is no reason for the TARGET_64BIT. OK? Built and tested on both riscv32-linux-gnu and riscv64-linux-gnu. Thanks, Andrew Pinski gcc/ChangeLog: PR target/106600 * config/riscv/bitmanip.md (bswap<mode>2): Remove condition on TARGET_64BIT as X is already conditional there. gcc/testsuite/ChangeLog: PR target/106600 * gcc.target/riscv/zbb_32_bswap-1.c: New test. * gcc.target/riscv/zbb_bswap-1.c: New test.
1 parent 55d8c54 commit cb2daf5

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

gcc/config/riscv/bitmanip.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
(define_insn "bswap<mode>2"
273273
[(set (match_operand:X 0 "register_operand" "=r")
274274
(bswap:X (match_operand:X 1 "register_operand" "r")))]
275-
"TARGET_64BIT && TARGET_ZBB"
275+
"TARGET_ZBB"
276276
"rev8\t%0,%1"
277277
[(set_attr "type" "bitmanip")])
278278

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-march=rv32gc_zbb -mabi=ilp32" } */
3+
/* { dg-skip-if "" { *-*-* } { "-O0" } } */
4+
5+
int foo(int n)
6+
{
7+
return __builtin_bswap32(n);
8+
}
9+
10+
/* { dg-final { scan-assembler "rev8" } } */
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-march=rv64gc_zbb -mabi=lp64" } */
3+
/* { dg-skip-if "" { *-*-* } { "-O0" } } */
4+
5+
int foo(int n)
6+
{
7+
return __builtin_bswap32(n);
8+
}
9+
10+
/* { dg-final { scan-assembler "rev8" } } */
11+

0 commit comments

Comments
 (0)