Skip to content

Commit b01b6dc

Browse files
apinski-caviumstephanosio
authored andcommitted
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. (cherry picked from commit cb2daf5) Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
1 parent 261c563 commit b01b6dc

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
@@ -228,7 +228,7 @@
228228
(define_insn "bswap<mode>2"
229229
[(set (match_operand:X 0 "register_operand" "=r")
230230
(bswap:X (match_operand:X 1 "register_operand" "r")))]
231-
"TARGET_64BIT && TARGET_ZBB"
231+
"TARGET_ZBB"
232232
"rev8\t%0,%1"
233233
[(set_attr "type" "bitmanip")])
234234

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)