For large immediate values in variable AND operations:
if their bit representation has two consecutive 0 sequences,
one starting from the MSB can use the bstrpick.d instruction,
and the bstrins.d instruction for the other.
For example, in the case 'var & 0x3fffffffefffffff':
Before:
lu12i.w $r12,-65537
ori $r12,$r12,4095
lu52i.d $r12,$r12,0x3ff
and $r4,$r4,$r12
* config/loongarch/loongarch-protos.h
(loongarch_use_bstrins_bstrpick_for_and): New proto.
* config/loongarch/loongarch.cc
(loongarch_use_bstrins_bstrpick_for_and): Decide whether
to optimize.
(loongarch_rtx_costs): Adjust the cost of AND operation.
* config/loongarch/loongarch.md
(bstrins_bstrpick_for_and_imm<mode>): New insn_and_split.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/and-large-immediate-opt.c: New test.