https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88461
Bug ID: 88461 Summary: AVX512: gcc should keep value in kN registers if possible 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: --- I tried to write piece of code which used new AVX512 logic instructions which works on kN registers. It turned out that gcc was moving intermediate values back and forth between kN and eax, what resulted in very poor code. Example was compiled using gcc 8.2 with -O3 -march=skylake-avx512 [code] #include <immintrin.h> #include <stdint.h> int test(uint16_t* data, int a) { __m128i v = _mm_load_si128((const __m128i*)data); __mmask8 m = _mm_testn_epi16_mask(v, v); m = _kshiftli_mask16(m, 1); m = _kandn_mask16(m, a); return m; } [/code] [asm] test(unsigned short*, int): vmovdqa64 xmm0, XMMWORD PTR [rdi] kmovw k5, esi vptestnmw k1, xmm0, xmm0 kmovb eax, k1 kmovw k2, eax kshiftlw k0, k2, 1 kmovw eax, k0 movzx eax, al kmovw k4, eax kandnw k3, k4, k5 kmovw eax, k3 movzx eax, al ret [/asm]