diff options
| author | Deng Jianbo <dengjianbo@loongson.cn> | 2025-11-14 10:22:10 +0800 |
|---|---|---|
| committer | Lulu Cheng <chenglulu@loongson.cn> | 2025-11-22 15:13:25 +0800 |
| commit | 0483d99124fbd2c6dfebb0c735fdf077b37838da (patch) | |
| tree | 4d1b8c20889d29495c304a6ffd68fba47b0bc8f3 /gcc/config/loongarch/predicates.md | |
| parent | 4962d1309be98585ed05980eb7064dd5cc0d113a (diff) | |
LoongArch: Optimize statement to use bstrins.{w|d}
For statement (a << imm1) | (b & imm2), in case the imm2 equals to
(1 << imm1) - 1, it can be optimized to use bstrins.{w|d} instruction.
gcc/ChangeLog:
* config/loongarch/loongarch.md
(*bstrins_w_for_ior_ashift_and_extend): New template.
(*bstrins_d_for_ior_ashift_and): New template.
* config/loongarch/predicates.md (const_uimm63_operand): New
predicate.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/bstrins-5.c: New test.
* gcc.target/loongarch/bstrins-6.c: New test.
Diffstat (limited to 'gcc/config/loongarch/predicates.md')
| -rw-r--r-- | gcc/config/loongarch/predicates.md | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/config/loongarch/predicates.md b/gcc/config/loongarch/predicates.md index 957215ad89a..7e4d8abc822 100644 --- a/gcc/config/loongarch/predicates.md +++ b/gcc/config/loongarch/predicates.md @@ -135,6 +135,10 @@ (and (match_code "const_int") (match_test "IN_RANGE (INTVAL (op), -16, 15)"))) +(define_predicate "const_uimm63_operand" + (and (match_code "const_int") + (match_test "IN_RANGE (INTVAL (op), 0, 63)"))) + (define_predicate "const_imm10_operand" (and (match_code "const_int") (match_test "IMM10_OPERAND (INTVAL (op))"))) |
