This is an archive of the discontinued LLVM Phabricator instance.

[X86] Enable EVEX GFNI instructions without avx512bw.
ClosedPublic

Authored by craig.topper on Oct 30 2022, 1:12 AM.

Details

Summary

We only really need avx512bw for masking 256 or 512 bit GFNI
instructions due to the need for v32i1 or v64i1.

I wanted to enable 128-bit intrinsics with avx512vl, but the
__builtin_ia32_selectb_128 used in the header file requires avx512bw.
The codegen test for the same is also not using a masked instruction
because vselect with v16i1 mask and v16i8 is not legal so is expanded
before isel. To fix these issues we need a mask specific builtin and a
mask specific ISD opcode.

Fixes PR58687.

Diff Detail

Event Timeline

craig.topper created this revision.Oct 30 2022, 1:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 30 2022, 1:12 AM
craig.topper requested review of this revision.Oct 30 2022, 1:12 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 30 2022, 1:12 AM
pengfei accepted this revision.Oct 31 2022, 12:21 AM

LGTM, thanks for the patch!

llvm/test/CodeGen/X86/avx512-gfni-intrinsics.ll
29

Since we are able to lower the mask version intrinsics, we have 3 choices for the FE support:

  1. Still disallow Clang intrinsics for AVX512F. This matches with GCC too;
  2. Allow the mask intrinsics as well. This matches with Intrinsic Guide and SDM somehow;
  3. And mixed for AVX512F and AVX512BW as in this revision;

I slightly prefer to 1). I think the intention of the EVEX design is to use the masked instructions directly, so it should always imply AVX512BW in reality. But I'm fine with any way.

This revision is now accepted and ready to land.Oct 31 2022, 12:21 AM
craig.topper added inline comments.Oct 31 2022, 12:56 AM
llvm/test/CodeGen/X86/avx512-gfni-intrinsics.ll
29

I think gcc allows the 128-bit mask with avx512vl only. The 256 and 512 require avx512bw due to needing kmovd and kmovq to have a large enough mask register.

This revision was landed with ongoing or failed builds.Oct 31 2022, 10:32 AM
This revision was automatically updated to reflect the committed changes.