https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111252
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Xi Ruoyao <xry...@gcc.gnu.org>: https://gcc.gnu.org/g:5b857e87201335148f23ec7134cf7fbf97c04c72 commit r14-3773-g5b857e87201335148f23ec7134cf7fbf97c04c72 Author: Xi Ruoyao <xry...@xry111.site> Date: Tue Sep 5 19:42:30 2023 +0800 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.