Skip to content

Commit b42e14e

Browse files
[clang] Enable SSE4.1 intrinsics for Windows MSVC targets - Issue #172104
1 parent 4d15af1 commit b42e14e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ bool X86TargetInfo::initFeatureMap(
157157
if (getTriple().getArch() == llvm::Triple::x86_64)
158158
setFeatureEnabled(Features, "sse2", true);
159159

160+
// Enable SSE4.1 for Windows MSVC targets to support SIMD intrinsics like
161+
// _mm_mullo_epi32 without requiring explicit /arch: flags.
162+
if ((getTriple().getArch() == llvm::Triple::x86_64 ||
163+
getTriple().getArch() == llvm::Triple::x86) &&
164+
getTriple().isWindowsMSVCEnvironment()) {
165+
setFeatureEnabled(Features, "sse4.1", true);
166+
}
167+
160168
using namespace llvm::X86;
161169

162170
SmallVector<StringRef, 16> CPUFeatures;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_cc1 -x c -triple i386-pc-windows-msvc -fsyntax-only %s
2+
// RUN: %clang_cc1 -x c -triple x86_64-pc-windows-msvc -fsyntax-only %s
3+
// RUN: %clang_cc1 -x c -triple i386-unknown-linux-gnu -fsyntax-only %s
4+
// RUN: %clang_cc1 -x c -triple x86_64-unknown-linux-gnu -fsyntax-only %s
5+
6+
// This test verifies that SSE4.1 intrinsics are available by default
7+
// without requiring explicit /arch: or -msse4.1 flags.
8+
9+
#include <immintrin.h>
10+
11+
void test_sse41_intrinsics(void) {
12+
__m128i a = _mm_set1_epi32(1);
13+
__m128i b = _mm_set1_epi32(2);
14+
__m128i result = _mm_mullo_epi32(a, b);
15+
(void)result;
16+
}

0 commit comments

Comments
 (0)