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

            Bug ID: 109167
           Summary: rs6000: _mm_slli_si128 and _mm_bslli_si128 are
                    inconsistent in wrapper header
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: linkw at gcc dot gnu.org
  Target Milestone: ---

When I was investigating PR109082, I happened to find that in
gcc/config/rs6000/emmintrin.h, we have different definitions for _mm_slli_si128
and _mm_bslli_si128 as follow:

extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_bslli_si128 (__m128i __A, const int __N)
{
  __v16qu __result;
  const __v16qu __zeros = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

  if (__N >= 0 && __N < 16)
    __result = vec_sld ((__v16qu) __A, __zeros, __N);
  else
    __result = __zeros;

  return (__m128i) __result;
}

extern __inline  __m128i __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_slli_si128 (__m128i __A, const int _imm5)
{
  __v16qu __result;
  const __v16qu __zeros = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

  if (_imm5 == 0)
    return __A;
  else if (_imm5 > 0 && _imm5 < 16)
#ifdef __LITTLE_ENDIAN__
    __result = vec_sld ((__v16qu) __A, __zeros, _imm5);
#else
    __result = vec_sld (__zeros, (__v16qu) __A, (16 - _imm5));
#endif
  else
    __result = __zeros;

  return (__m128i) __result;
}

But actually as ./gcc/config/i386/emmintrin.h, they should be the same:

#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_bsrli_si128 (__m128i __A, const int __N)
{
  return (__m128i)__builtin_ia32_psrldqi128 (__A, __N * 8);
}

extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_bslli_si128 (__m128i __A, const int __N)
{
  return (__m128i)__builtin_ia32_pslldqi128 (__A, __N * 8);
}

extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_srli_si128 (__m128i __A, const int __N)
{
  return (__m128i)__builtin_ia32_psrldqi128 (__A, __N * 8);
}

extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_slli_si128 (__m128i __A, const int __N)
{
  return (__m128i)__builtin_ia32_pslldqi128 (__A, __N * 8);
}
#else
#define _mm_bsrli_si128(A, N) \
  ((__m128i)__builtin_ia32_psrldqi128 ((__m128i)(A), (int)(N) * 8))
#define _mm_bslli_si128(A, N) \
  ((__m128i)__builtin_ia32_pslldqi128 ((__m128i)(A), (int)(N) * 8))
#define _mm_srli_si128(A, N) \
  ((__m128i)__builtin_ia32_psrldqi128 ((__m128i)(A), (int)(N) * 8))
#define _mm_slli_si128(A, N) \
  ((__m128i)__builtin_ia32_pslldqi128 ((__m128i)(A), (int)(N) * 8))
#endif

Reply via email to