Skip to content

clang-cl doesn't compile MSVC code using SIMD intrinsics #172104

@dsharlet

Description

@dsharlet

For example:

#include <immintrin.h>

__m128i f(__m128i a, __m128i b) {
  return _mm_mullo_epi32(a, b);  // SSE4.1 intrinsic
}

This builds using Microsoft's cl.

However, with clang-cl, we get: error: use of undeclared identifier '_mm_mullo_epi32'; did you mean '_mm_mullo_epi16'?

We can specify /arch:AVX to solve the problem. However, this means that the compiler is then free to use AVX instructions, which is not what we want if we want to only target SSE4.1. MSVC does not appear to have a /arch:SSE4.1 option: https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170.

We can specify /clang:-msse4.1 to solve the problem, but this means that clang-cl is not a clean replacement of cl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-cl`clang-cl` driver. Don't use for other compiler partsclang:headersHeaders provided by Clang, e.g. for intrinsicsdiverges-from:msvcDoes the clang frontend diverge from msvc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions