This is an archive of the discontinued LLVM Phabricator instance.

[X86][AVX512FP16] Relax limitation to AVX512FP16 intrinsics. NFCI
ClosedPublic

Authored by pengfei on Aug 21 2022, 7:24 PM.

Details

Summary

Since we have enabled the support for _Float16 on SSE2, we can relax
the limitation for AVX512FP16 now. This helps for user to use AVX512FP16
mixed with unsupported versions, e.g., multiversioning.

Also fix lit fails due to missing const modifier. Found during this change.

Diff Detail

Event Timeline

pengfei created this revision.Aug 21 2022, 7:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2022, 7:24 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
pengfei requested review of this revision.Aug 21 2022, 7:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2022, 7:24 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
pengfei updated this revision to Diff 454362.Aug 21 2022, 7:39 PM

Don't know why, but check !defined(__SSE2__) leads to compiler_builtins_x86.c fails like below. Move the check into avx512[vl]fp16intrin.h instead.

error: 'error' diagnostics seen but not expected:
  File /export/users/pengfeiw/llvm-project/clang/test/Modules/compiler_builtins_x86.c Line 8: could not build module '_Builtin_intrinsics'
1 error generated.

Should the const change be a separate patch? They feel unrelated.

pengfei updated this revision to Diff 454475.Aug 22 2022, 5:57 AM

Rebased on D132372.

Should the const change be a separate patch? They feel unrelated.

Done. The change results in lit test fails.

RKSimon added inline comments.Aug 22 2022, 7:13 AM
clang/lib/Headers/avx512fp16intrin.h
13

Doesn't this have to be the general case like in other places in the headers?

#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
    defined(__SSE2__)
pengfei added inline comments.Aug 22 2022, 8:14 AM
clang/lib/Headers/avx512fp16intrin.h
13

I don't think so. !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || defined(__AVX512FP16__) has already been checked in immintrin.h

So if we are preprocessing here, the above condition must be true. Since AVX512FP16 implies SSE2, the new condition is constant ture.

RKSimon added inline comments.Aug 22 2022, 9:33 AM
clang/lib/Headers/avx512fp16intrin.h
13

got it - cheers

RKSimon accepted this revision.Aug 22 2022, 11:10 AM

LGTM

clang/lib/Headers/immintrin.h
223

(style) - other uses in this header put the defined(AVX512VL) after:

(defined(__AVX512FP16__) && defined(__AVX512VL__))
This revision is now accepted and ready to land.Aug 22 2022, 11:10 AM
This revision was landed with ongoing or failed builds.Aug 22 2022, 8:36 PM
This revision was automatically updated to reflect the committed changes.

Thanks @RKSimon

clang/lib/Headers/immintrin.h
223

This was copy+paste from AVX512BF16. Just have a look, puting it ahead seems a little more that the other. So let leave it as is :)