https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88465

            Bug ID: 88465
           Summary: AVX512: optimize loading of constant values to kN
                    registers
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugzi...@poradnik-webmastera.com
  Target Milestone: ---

When constant value is loaded into kN register, gcc puts it into eax first, and
then moved to kN register:

[code]
#include <immintrin.h>
#include <stdint.h>

__mmask8 test(__mmask8 m)
{
    __mmask8 m2 = _kand_mask8(m, 3);
    return m2;
}
[/code]

[asm]
test(unsigned char):
        mov     eax, 3
        kmovb   k1, eax
        kmovb   k2, edi
        kandb   k0, k1, k2
        kmovb   eax, k0
        ret
[/asm]

icc uses one instruction for this. https://godbolt.org/ displayed it as "null",
but most probably this is wrong name:

[asm]
test(unsigned char):
        vkmovb    k0, edi                                       #6.19
        null      k1, 3                                         #6.19
        kandb     k2, k0, k1                                    #6.19
        vkmovb    eax, k2                                       #6.19
        ret                                                     #7.12
[/asm]

You can also use instructions kxor and kxnor to load 0 and -1.

Reply via email to