]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Simplify using bstr{ins,pick} instructions for and
authorXi Ruoyao <xry111@xry111.site>
Thu, 5 Sep 2024 09:53:41 +0000 (17:53 +0800)
committerXi Ruoyao <xry111@xry111.site>
Mon, 20 Jan 2025 13:27:52 +0000 (21:27 +0800)
commitf3bedc9a3b8b7dd3911272731a1ea595621e13cd
treef3a956db1e876ead7471772654de605f61e4accd
parent67b10ee872197ba53524db4f0ca777899e27b151
LoongArch: Simplify using bstr{ins,pick} instructions for and

For bstrins, we can merge it into and<mode>3 instead of having a
separate define_insn.

For bstrpick, we can use the constraints to ensure the first source
register and the destination register are the same hardware register,
instead of emitting a move manually.

This will simplify the next commit where we'll reassociate bitwise
and left shift for better code generation.

gcc/ChangeLog:

* config/loongarch/constraints.md (Yy): New define_constriant.
* config/loongarch/loongarch.cc (loongarch_print_operand):
For "%M", output the index of bits to be used with
bstrins/bstrpick.
* config/loongarch/predicates.md (ins_zero_bitmask_operand):
Exclude low_bitmask_operand as for low_bitmask_operand it's
always better to use bstrpick instead of bstrins.
(and_operand): New define_predicate.
* config/loongarch/loongarch.md (any_or): New
define_code_iterator.
(bitwise_operand): New define_code_attr.
(*<optab:any_or><mode:GPR>3): New define_insn.
(*and<mode:GPR>3): New define_insn.
(<optab:any_bitwise><mode:X>3): New define_expand.
(and<mode>3_extended): Remove, replaced by the 3rd alternative
of *and<mode:GPR>3.
(bstrins_<mode>_for_mask): Remove, replaced by the 4th
alternative of *and<mode:GPR>3.
(*<optab:any_bitwise>si3_internal): Remove, already covered by
the *<optab:any_or><mode:GPR>3 and *and<mode:GPR>3 templates.
gcc/config/loongarch/constraints.md
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.md
gcc/config/loongarch/predicates.md