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

            Bug ID: 126065
           Summary: Optimizer fails to optimize kxnor for AVX512
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: postmaster at raasu dot org
  Target Milestone: ---

With simple code:

> #include <x86intrin.h>
> 
> int main(void) {
>     __mmask16 target_mask = _kxnor_mask16((__mmask16)0, (__mmask16)0);
>     __mmask16 mask = _kshiftri_mask16(target_mask, 9);
>     return _mm512_mask2int(mask);
> }


GCC 16.1.0 generates using "-mavx512bw -mavx512vl -mavx512dq -O2" following
assembly code:

> "main":
>         mov     eax, 127
>         kxorw   k0, k0, k0
>         kxnorw  k0, k0, k0
>         kshiftrw        k0, k0, 9
>         ret

"mov     eax, 127" should be the only line generated with optimizations
enabled, the following three lines are redundant although missing the last
"kmovw eax, k0" that actually got optimized and reordered as the first line.

"kxorw   k0, k0, k0" is completely unnecessary as "kxnorw   k0, k0, k0" is
already fused XOR+NOT.

Seems to be similar to bug 88465.

Reply via email to