[vlc-devel] [PATCH] startcode_helper: ensure dependencies between asm blocks

Marvin Scholz epirat07 at gmail.com
Mon Sep 14 11:42:23 CEST 2020



On 14 Sep 2020, at 11:33, Francois Cartegnie wrote:

> fixed to use the portable __has_attribute check
> as mentioned by ePirat
>
> ---
>  modules/packetizer/startcode_helper.h | 35 
> +++++++++++++++++++++------
>  1 file changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/modules/packetizer/startcode_helper.h 
> b/modules/packetizer/startcode_helper.h
> index 2b61e5cf98..7f66a8e76f 100644
> --- a/modules/packetizer/startcode_helper.h
> +++ b/modules/packetizer/startcode_helper.h
> @@ -23,7 +23,17 @@
>  #include <vlc_cpu.h>
>
>  #if !defined(CAN_COMPILE_SSE2) && defined(HAVE_SSE2_INTRINSICS)
> -   #include <emmintrin.h>
> +#  include <emmintrin.h>
> +#endif
> +
> +#if defined __has_attribute
> +#  if __has_attribute(__vector_size__)
> +#  define HAS_ATTRIBUTE_VECTORSIZE
> +#  endif
> +#endif
> +
> +#ifdef HAS_ATTRIBUTE_VECTORSIZE
> +typedef unsigned char v16qu __attribute__((__vector_size__(16)));
>  #endif
>
>  /* Looks up efficiently for an AnnexB startcode 0x00 0x00 0x01
> @@ -63,26 +73,35 @@ static inline const uint8_t * 
> startcode_FindAnnexB_SSE2( const uint8_t *p, const
>      alignedend = end - ((intptr_t) end & 15);
>      if( alignedend > p )
>      {
> -#ifdef CAN_COMPILE_SSE2
> -        asm volatile(
> -            "pxor   %%xmm1, %%xmm1\n"
> -            ::: "xmm1"
> -        );
> +#if defined(CAN_COMPILE_SSE2) && __has_attribute(__vector_size__)

I think this should be: '&& defined(HAS_ATTRIBUTE_VECTORSIZE)' ?

> +        const v16qu zeros = { 0 };
>  #else
> -        __m128i zeros = _mm_set1_epi8( 0x00 );
> +        const __m128i zeros = _mm_set1_epi8( 0x00 );
>  #endif
>          for( ; p < alignedend; p += 16)
>          {
>              uint32_t match;
>  #ifdef CAN_COMPILE_SSE2
> +#  ifdef HAS_ATTRIBUTE_VECTORSIZE
> +            asm volatile(
> +                "movdqa   0(%[v]),   %%xmm0\n"
> +                "pcmpeqb %[czero],   %%xmm0\n"
> +                "pmovmskb  %%xmm0,   %[match]\n"
> +                : [match]"=r"(match)
> +                : [v]"r"(p), [czero]"x"(zeros)
> +                : "xmm0"
> +            );
> +#  else
>              asm volatile(
>                  "movdqa   0(%[v]),   %%xmm0\n"
> +                "pxor      %%xmm1,   %%xmm1\n"
>                  "pcmpeqb   %%xmm1,   %%xmm0\n"
>                  "pmovmskb  %%xmm0,   %[match]\n"
>                  : [match]"=r"(match)
>                  : [v]"r"(p)
> -                : "xmm0"
> +                : "xmm0", "xmm1"
>              );
> +#  endif
>  #else
>              __m128i v = _mm_load_si128((__m128i*)p);
>              __m128i res = _mm_cmpeq_epi8( zeros, v );
> -- 
> 2.25.4
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list