forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PR 106601: __builtin_bswap16 code gen could be improved with ZBB …
…enabled The default expansion for bswap16 is two extractions (shift/and) followed by an insertation (ior) and then a zero extend. This can be improved with ZBB enabled to just full byteswap followed by a (logical) shift right. This patch adds a new pattern for this which does that. OK? Built and tested on riscv32-linux-gnu and riscv64-linux-gnu. gcc/ChangeLog: PR target/106601 * config/riscv/bitmanip.md (bswaphi2): New pattern. gcc/testsuite/ChangeLog: PR target/106601 * gcc.target/riscv/zbb_32_bswap-2.c: New test. * gcc.target/riscv/zbb_bswap-2.c: New test.
- Loading branch information
1 parent
cb2daf5
commit e5e6983
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv32gc_zbb -mabi=ilp32" } */ | ||
/* { dg-skip-if "" { *-*-* } { "-O0" } } */ | ||
|
||
int foo(int n) | ||
{ | ||
return __builtin_bswap16(n); | ||
} | ||
|
||
/* { dg-final { scan-assembler "rev8" } } */ | ||
/* { dg-final { scan-assembler "srli" } } */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gc_zbb -mabi=lp64" } */ | ||
/* { dg-skip-if "" { *-*-* } { "-O0" } } */ | ||
|
||
int foo(int n) | ||
{ | ||
return __builtin_bswap16(n); | ||
} | ||
|
||
/* { dg-final { scan-assembler "rev8" } } */ | ||
/* { dg-final { scan-assembler "srli" } } */ | ||
|