]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Use bstrins for "value & (-1u << const)"
authorXi Ruoyao <xry111@xry111.site>
Sun, 9 Jun 2024 06:43:48 +0000 (14:43 +0800)
committerXi Ruoyao <xry111@xry111.site>
Wed, 12 Jun 2024 12:38:41 +0000 (20:38 +0800)
commitd0da347a1dd6e57cb0e0c55fd654d81dde545cf8
tree300ab3ffe38b3d59909f105a498750978d094e9d
parent53c703888eb51314f762c8998dc9215871b12722
LoongArch: Use bstrins for "value & (-1u << const)"

A move/bstrins pair is as fast as a (addi.w|lu12i.w|lu32i.d|lu52i.d)/and
pair, and twice fast as a srli/slli pair.  When the src reg and the dst
reg happens to be the same, the move instruction can be optimized away.

gcc/ChangeLog:

* config/loongarch/predicates.md (high_bitmask_operand): New
predicate.
* config/loongarch/constraints.md (Yy): New constriant.
* config/loongarch/loongarch.md (and<mode>3_align): New
define_insn_and_split.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/bstrins-1.c: New test.
* gcc.target/loongarch/bstrins-2.c: New test.
gcc/config/loongarch/constraints.md
gcc/config/loongarch/loongarch.md
gcc/config/loongarch/predicates.md
gcc/testsuite/gcc.target/loongarch/bstrins-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/bstrins-2.c [new file with mode: 0644]