> On 24 Nov 2026, at 12:50, Jakub Jelinek <[email protected]> wrote:
>
> On Tue, Nov 24, 2026 at 09:53:39AM +0000, Kyrylo Tkachov wrote:
>>> --- a/gcc/optabs.def 2026-11-03 11:23:44.308599512 +0100
>>> +++ b/gcc/optabs.def 2026-11-04 17:23:29.398822447 +0100
>>> @@ -579,3 +579,5 @@ OPTAB_D (iorn_optab, "iorn$a3")
>>> OPTAB_D (aop_optab, "aop$a3")
>>> OPTAB_D (clmul_optab, "clmul$a3")
>>> OPTAB_D (clmul_widen_optab, "clmul_widen$a3")
>>> +OPTAB_D (bitcompress_optab, "bitcompress$a3")
>>> +OPTAB_D (bitexpand_optab, "bitexpand$a3")
>>
>>
>> Can you please documents the new optabs in the Standard Names section of
>> md.texi.
>
> I knew I forgot something... ;)
Thanks! LGTM FWIW.
Kyrill
>
> Here is incremental patch to document those.
>
> 2026-11-24 Jakub Jelinek <[email protected]>
>
> * doc/md.texi (bitcompress@var{m}3, bitexpand@var{m}3): Document.
>
> --- a/gcc/doc/md.texi 2026-11-24 09:18:56.932109576 +0100
> +++ b/gcc/doc/md.texi 2026-11-24 12:45:31.006372253 +0100
> @@ -5437,6 +5437,54 @@ Neither @samp{clmul@var{m}3} nor @samp{c
> handle all operand values. They may @code{FAIL}, in which case the
> compiler falls back to another expansion.
>
> +@mdindex bitcompress@var{m}3
> +@item @samp{bitcompress@var{m}3}
> +Perform bit compression (parallel bit extract) of operands 1 and 2
> +and store result in operand 0. All three operands have the same scalar
> +integer mode @var{m}, and the operands are treated as unsigned.
> +This is equivalent to the C code:
> +@smallexample
> +unsigned_type r = 0;
> +for (int i = 0, j = 0; i < width; i++)
> + @{
> + bool mask_bit = (op1 >> i) & 1;
> + r |= (mask_bit & (op0 >> i)) << j;
> + j += mask_bit;
> + @}
> +op0 = r;
> +@end smallexample
> +where @code{width} is the bit size of mode @var{m}. A pattern in
> +mode @var{m} is also used for narrower operations, by zero extending
> +the operands to mode @var{m}.
> +
> +@samp{bitcompress@var{m}3} does not have to handle all operand values.
> +They may @code{FAIL}, in which case the compiler falls back to another
> +expansion.
> +
> +@mdindex bitexpand@var{m}3
> +@item @samp{bitexpand@var{m}3}
> +Perform bit expansion (parallel bit deposit) of operands 1 and 2
> +and store result in operand 0. All three operands have the same scalar
> +integer mode @var{m}, and the operands are treated as unsigned.
> +This is equivalent to the C code:
> +@smallexample
> +unsigned_type r = 0;
> +for (int i = 0, j = 0; i < width; i++)
> + @{
> + bool mask_bit = (op1 >> i) & 1;
> + r |= (mask_bit & (op0 >> j)) << i;
> + j += mask_bit;
> + @}
> +op0 = r;
> +@end smallexample
> +where @code{width} is the bit size of mode @var{m}. A pattern in
> +mode @var{m} is also used for narrower operations, by zero extending
> +the operands to mode @var{m}.
> +
> +@samp{bitexpand@var{m}3} does not have to handle all operand values.
> +They may @code{FAIL}, in which case the compiler falls back to another
> +expansion.
> +
> @mdindex neg@var{m}2
> @mdindex ssneg@var{m}2
> @mdindex usneg@var{m}2
>
>
> Jakub
>