RISC-V: add TARGET_ZBKB to the condition of bswapsi2, bswapdi2 and rotr<mode>3 patterns

Message ID 20230410105640.6510-1-mynameisxiaou@gmail.com
State Accepted
Headers
Series RISC-V: add TARGET_ZBKB to the condition of bswapsi2, bswapdi2 and rotr<mode>3 patterns |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Lin Sinan April 10, 2023, 10:56 a.m. UTC
  From: Sinan Lin <sinan.lin@linux.alibaba.com>

tell gcc that zbkb has these two spn to enable some optimizations. e.g.
1) the rrotate_expr could match to rotrm3 during expand; 2) hook up
__builtin_bswap64 with `rev8` in zbkb64.
---
 gcc/config/riscv/bitmanip.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Jeff Law April 10, 2023, 2:55 p.m. UTC | #1
On 4/10/23 04:56, Lin Sinan wrote:
> From: Sinan Lin <sinan.lin@linux.alibaba.com>
> 
> tell gcc that zbkb has these two spn to enable some optimizations. e.g.
> 1) the rrotate_expr could match to rotrm3 during expand; 2) hook up
> __builtin_bswap64 with `rev8` in zbkb64.
> ---
>   gcc/config/riscv/bitmanip.md | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
Deferred to gcc-14 as the trunk is not currently open for development.

jeff
  
Jeff Law April 18, 2023, 6:27 p.m. UTC | #2
On 4/10/23 04:56, Lin Sinan wrote:
> From: Sinan Lin <sinan.lin@linux.alibaba.com>
> 
> tell gcc that zbkb has these two spn to enable some optimizations. e.g.
> 1) the rrotate_expr could match to rotrm3 during expand; 2) hook up
> __builtin_bswap64 with `rev8` in zbkb64.
Thanks.  I pushed this to the trunk.

jeff
  

Patch

diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md
index 7aa591689ba..3ed9f5d403a 100644
--- a/gcc/config/riscv/bitmanip.md
+++ b/gcc/config/riscv/bitmanip.md
@@ -297,7 +297,7 @@ 
   [(set (match_operand:GPR 0 "register_operand")
 	(rotatert:GPR (match_operand:GPR 1 "register_operand")
 		     (match_operand:QI 2 "arith_operand")))]
-  "TARGET_ZBB || TARGET_XTHEADBB"
+  "TARGET_ZBB || TARGET_XTHEADBB || TARGET_ZBKB"
 {
   if (TARGET_XTHEADBB && !immediate_operand (operands[2], VOIDmode))
     FAIL;
@@ -362,12 +362,12 @@ 
 (define_expand "bswapdi2"
   [(set (match_operand:DI 0 "register_operand")
 	(bswap:DI (match_operand:DI 1 "register_operand")))]
-  "TARGET_64BIT && (TARGET_ZBB || TARGET_XTHEADBB)")
+  "TARGET_64BIT && (TARGET_ZBB || TARGET_XTHEADBB || TARGET_ZBKB)")
 
 (define_expand "bswapsi2"
   [(set (match_operand:SI 0 "register_operand")
 	(bswap:SI (match_operand:SI 1 "register_operand")))]
-  "(!TARGET_64BIT && TARGET_ZBB) || TARGET_XTHEADBB")
+  "(!TARGET_64BIT && (TARGET_ZBB || TARGET_ZBKB)) || TARGET_XTHEADBB")
 
 (define_insn "*bswap<mode>2"
   [(set (match_operand:X 0 "register_operand" "=r")