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

            Bug ID: 80338
           Summary: no such instruction: kmovb, operand type mismatch for
                    vrcp14ps
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m...@sven-woop.de
  Target Milestone: ---

The following code fails to compile with GCC 6.3 and trunk:

#include <immintrin.h>

inline __attribute__((always_inline)) const __m128 rcp2  ( const __m128& a )
{
#if defined(__AVX512VL__)
  const __m128 r = _mm_rcp14_ps(a);
#else
  const __m128 r = _mm_rcp_ps(a);
#endif

#if defined(__AVX2__)
  const __m128 res = _mm_mul_ps(r,_mm_fnmadd_ps(r, a, _mm_set1_ps(2.0f)));
#else
  const __m128 res = _mm_mul_ps(r,_mm_sub_ps(_mm_set1_ps(2.0f), _mm_mul_ps(r,
a)));
  //return _mm_sub_ps(_mm_add_ps(r, r), _mm_mul_ps(_mm_mul_ps(r, r), a));
#endif

  return res;
}

inline __attribute__((always_inline)) __m128 load4 ( const void* const a ) {
return _mm_load_ps((float*)a); }

inline __attribute__((always_inline)) const __m128 msub  ( const __m128& a,
const __m128& b, const __m128& c) { return _mm_fmsub_ps(a,b,c); }

void test(__m128 ray_org, __m128 ray_dir, float ray_tnear, float ray_tfar)
{
  char* stack[100];
  char** stackPtr = stack+1;

  const __m128 ray_rdir = rcp2(ray_dir);
  __m128 rdir = _mm_set1_ps(*(float*)&ray_rdir);
  __m128 org_rdir = _mm_set1_ps(*(float*)&ray_org);

  /* pop loop */
  while (true) pop:
  {
    stackPtr--;
    char* cur = (char*) *stackPtr;

    /* downtraversal loop */
    while (true)
    {
      const __m128 tNearX = msub(load4((float*)((const char*)&cur+0)), rdir,
org_rdir);
      const __m128 tFarX  = msub(load4((float*)((const char*)&cur+3)), rdir,
org_rdir);
      const __m128 tNear_ = _mm_max_ps(tNearX,_mm_set1_ps(ray_tnear));
      const __m128 tFar_  = _mm_min_ps(tFarX ,_mm_set1_ps(ray_tfar));
      const __mmask8 vmask = _mm_cmp_ps_mask(tNear_, tFar_, _MM_CMPINT_LE);
      size_t mask = _mm512_kmov(vmask);
      if (mask == 0)
        goto pop;
    }
  }
}

Command line:
g++ -mavx512f -mavx512dq -mavx512cd -mavx512bw -mavx512vl -mf16c -mavx2 -mfma
-mlzcnt -mbmi -mbmi2 test.cpp -c -o test

Output:
/tmp/ccNhXh57.s: Assembler messages:
/tmp/ccNhXh57.s:26: Error: no such instruction: `kmovb %eax,%k2'
/tmp/ccNhXh57.s:27: Error: operand type mismatch for `vrcp14ps'
/tmp/ccNhXh57.s:125: Error: no such instruction: `kmovb %eax,%k3'
/tmp/ccNhXh57.s:126: Error: operand type mismatch for `vcmpps'
/tmp/ccNhXh57.s:127: Error: no such instruction: `kmovb %k1,-49(%rbp)'

Reply via email to