This is an archive of the discontinued LLVM Phabricator instance.

[CL] Add argument "-mssse3" in clang-cl
AbandonedPublic

Authored by Qfrost911 on Oct 20 2022, 6:39 AM.

Details

Summary

By default, "SSE" is supported by MSVC, but it is not supported by clang-cl

__m128i x1, x2;
 __m128i x3 = _mm_shuffle_epi8(x1, x2);

This patch add argument "-mssse3" if it is under the CLMode.

Diff Detail

Event Timeline

Qfrost911 created this revision.Oct 20 2022, 6:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 6:39 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
Qfrost911 requested review of this revision.Oct 20 2022, 6:39 AM

This doesn't look right to me.

MSVC always accepts intrinsics I think, but in clang you have to pass` -mssse3` to your compile invocation, and then clang will:

  1. Accept intrinsics
  2. Use SSSE3 in code it generates for normal C

If you add this flag unconditionally, clang will generate SSSE3 even for normal code, which won't work on machines that don't support that instruction set.

If you want to use SSSE3 with clang-cl, you have to pass -mssse3 to it as a compiler flag. It will then generate SSSE3 for "normal" code as well.

The usual approach is to put your SSSE3 code in a dedicated file, build that with -mssse3, and then call functions in it behind runtime checks.

(On the other hand, MSVC can generate SSSE3 only for intrinsics but not for the rest of the code.)

Qfrost911 abandoned this revision.Oct 20 2022, 8:01 PM