[Patch] x86: Enable GCC support for Intel AVX-VNNI extension

Hongtao Liu crazylht@gmail.com
Mon Nov 9 10:33:00 GMT 2020


>
> +      /* Support unified builtin.  */
> +      || (mask2 == OPTION_MASK_ISA2_AVXVNNI)
>
> I don't think we gain anything with unified builtins. Better, just
> introduce separate builtins, e.g for
>

Unified builtins are used for unified intrinsics, intrinsics users may prefer
same interface and let compiler decide encoding version. Separate
buitins may cause
some defination ambiguous when target attribute is used, see avx-vnni-2.c.
We also provide separate intrinsics interface for compatibility with
different compilers(llvm/msvc/icc).

> -BDESC (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL, 0,
> CODE_FOR_vpdpbusd_v8si, "__builtin_ia32_vpdpbusd_v8si",
> IX86_BUILTIN_VPDPBUSDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
> +BDESC (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL,
> OPTION_MASK_ISA2_AVXVNNI, CODE_FOR_vpdpbusd_v8si,
> "__builtin_ia32_vpdpbusd_v8si", IX86_BUILTIN_VPDPBUSDV8SI, UNKNOWN,
> (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
>
> add __builtin_ia32_vpdbusd_avx_v8si with the same CODE_FOR.
>
> This will remove the need for:
>
> +  if ((((bisa & (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL))
> +    == (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL))
> +       || (bisa2 & OPTION_MASK_ISA2_AVXVNNI) != 0)
> +      && (((isa & (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL))
> +       == (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL))
> +      || (isa2 & OPTION_MASK_ISA2_AVXVNNI) != 0))
> +    {
> +      isa |= OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL;
> +      isa2 |= OPTION_MASK_ISA2_AVXVNNI;
> +    }
>
> which is already complex with AVX512VL processing.
>
> +#ifdef __AVXVNNI__
> +#define _mm256_dpbusd_avx_epi32(A, B, C) \
> +  _mm256_dpbusd_epi32((A), (B), (C))
> +#define _mm_dpbusd_avx_epi32(A, B, C) \
> +  _mm_dpbusd_epi32((A), (B), (C))
> +#define _mm256_dpbusds_avx_epi32(A, B, C) \
> +  _mm256_dpbusds_epi32((A), (B), (C))
> +#define _mm_dpbusds_avx_epi32(A, B, C) \
> +  _mm_dpbusds_epi32((A), (B), (C))
> +#define _mm256_dpwssd_avx_epi32(A, B, C) \
> +  _mm256_dpwssd_epi32((A), (B), (C))
> +#define _mm_dpwssd_avx_epi32(A, B, C) \
> +  _mm_dpwssd_epi32((A), (B), (C))
> +#define _mm256_dpwssds_avx_epi32(A, B, C) \
> +  _mm256_dpwssds_epi32((A), (B), (C))
> +#define _mm_dpwssds_avx_epi32(A, B, C) \
> +  _mm_dpwssds_epi32((A), (B), (C))
> +#endif /* __AVXVNNI__ */
> +
>
> The above won't be needed with separate builtins.
>
> Please repost the patch, I think that the following part(s) of the
> patch were already committed via another patch:
>
> @@ -399,8 +403,8 @@ ix86_handle_option (struct gcc_options *opts,
>      {
>        opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE_UNSET;
>        opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE_UNSET;
> -      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512F_UNSET;
> -      opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512F_UNSET;
> +      opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX2_UNSET;
> +      opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX2_UNSET;
>      }
>        return true;
>

Yes.

> No review for the sse.md and for testcases.
>
> Uros.

Update the patch based on latest trunk.

--
BR,
Hongtao
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AVX_VNNI_v2.patch
Type: text/x-patch
Size: 90355 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201109/4c471d1c/attachment-0001.bin>


More information about the Gcc-patches mailing list