]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Use bstrins instruction for (a & ~mask) and (a & mask) | (b & ~mask) ...
authorXi Ruoyao <xry111@xry111.site>
Tue, 5 Sep 2023 11:42:30 +0000 (19:42 +0800)
committerXi Ruoyao <xry111@xry111.site>
Thu, 7 Sep 2023 07:53:25 +0000 (15:53 +0800)
commit5b857e87201335148f23ec7134cf7fbf97c04c72
tree84206204a94fa7a479dced08c34df28705cf8dc5
parentb1ca841b8972e546570553df3e61326c86135404
LoongArch: Use bstrins instruction for (a & ~mask) and (a & mask) | (b & ~mask) [PR111252]

If mask is a constant with value ((1 << N) - 1) << M we can perform this
optimization.

gcc/ChangeLog:

PR target/111252
* config/loongarch/loongarch-protos.h
(loongarch_pre_reload_split): Declare new function.
(loongarch_use_bstrins_for_ior_with_mask): Likewise.
* config/loongarch/loongarch.cc
(loongarch_pre_reload_split): Implement.
(loongarch_use_bstrins_for_ior_with_mask): Likewise.
* config/loongarch/predicates.md (ins_zero_bitmask_operand):
New predicate.
* config/loongarch/loongarch.md (bstrins_<mode>_for_mask):
New define_insn_and_split.
(bstrins_<mode>_for_ior_mask): Likewise.
(define_peephole2): Further optimize code sequence produced by
bstrins_<mode>_for_ior_mask if possible.

gcc/testsuite/ChangeLog:

* g++.target/loongarch/bstrins-compile.C: New test.
* g++.target/loongarch/bstrins-run.C: New test.
gcc/config/loongarch/loongarch-protos.h
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.md
gcc/config/loongarch/predicates.md
gcc/testsuite/g++.target/loongarch/bstrins-compile.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/bstrins-run.C [new file with mode: 0644]