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

            Bug ID: 92389
           Summary: Compiling with -march=icelake-client does not enable
                    __AVX512VPOPCNTDQ__
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tom.dillon at gmail dot com
  Target Milestone: ---

## Tested on:
gcc version 8.3.0 (Ubuntu 8.3.0-16ubuntu3~16.04) 
gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2~16.04.1) 

## Observed behavior:
When compiling on an icelake platform with -march=native or with
-march=icelake-client, GCC does not define __AVX512VPOPCNTDQ__.

$ gcc-8 -march=icelake-client -dM -E - < /dev/null | grep AVX512 | sort
#define __AVX512BITALG__ 1
#define __AVX512BW__ 1
#define __AVX512CD__ 1
#define __AVX512DQ__ 1
#define __AVX512F__ 1
#define __AVX512IFMA__ 1
#define __AVX512VBMI__ 1
#define __AVX512VBMI2__ 1
#define __AVX512VL__ 1
#define __AVX512VNNI__ 1

As a result, use of certain intrinsics that should be supported, like
_mm_popcnt_epi64, cause "target specific option mismatch" errors.

## Expected behavior:
 __AVX512VPOPCNTDQ__ should be defined since these instructions are supported
by the platform. For example, with clang:

$ clang-8 -march=icelake-client -dM -E - < /dev/null | grep AVX512 | sort
#define __AVX512BITALG__ 1
#define __AVX512BW__ 1
#define __AVX512CD__ 1
#define __AVX512DQ__ 1
#define __AVX512F__ 1
#define __AVX512IFMA__ 1
#define __AVX512VBMI__ 1
#define __AVX512VBMI2__ 1
#define __AVX512VL__ 1
#define __AVX512VNNI__ 1
#define __AVX512VPOPCNTDQ__ 1     <------------

## Workaround
As a workaround one can explicitly add -mavx512vpopcntdq

## Proposed Fix
It looks like the line here:
https://github.com/gcc-mirror/gcc/blob/a3f9c6f666e622f30eda441cd7ad8657a7a64bfe/gcc/config/i386/i386.h#L2439

Which reads:
const wide_int_bitmask PTA_ICELAKE_CLIENT = PTA_CANNONLAKE | PTA_AVX512VNNI
  | PTA_GFNI | PTA_VAES | PTA_AVX512VBMI2 | PTA_VPCLMULQDQ | PTA_AVX512BITALG
  | PTA_RDPID | PTA_CLWB;

Should read:
const wide_int_bitmask PTA_ICELAKE_CLIENT = PTA_CANNONLAKE | PTA_AVX512VNNI
  | PTA_GFNI | PTA_VAES | PTA_AVX512VBMI2 | PTA_VPCLMULQDQ | PTA_AVX512BITALG
  | PTA_RDPID | PTA_CLWB | PTA_AVX512VPOPCNTDQ;

Reply via email to