]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Optimize statement to use bstrins.{w|d}
authorDeng Jianbo <dengjianbo@loongson.cn>
Fri, 14 Nov 2025 02:22:10 +0000 (10:22 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Sat, 22 Nov 2025 07:13:25 +0000 (15:13 +0800)
commit0483d99124fbd2c6dfebb0c735fdf077b37838da
tree4d1b8c20889d29495c304a6ffd68fba47b0bc8f3
parent4962d1309be98585ed05980eb7064dd5cc0d113a
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.
gcc/config/loongarch/loongarch.md
gcc/config/loongarch/predicates.md
gcc/testsuite/gcc.target/loongarch/bstrins-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/bstrins-6.c [new file with mode: 0644]