Skip to content

Commit ba73aad

Browse files
committed
[X86] Add 'mmx' to all CPUs that have a version of 'sse' and weren't already enabling '3dnow'
All SSE capable CPUs have MMX. 3dnow implicitly enables MMX. We have code that detects if sse is enabled and implicitly enables MMX unless -mno-mmx is passed. So in most cases we were already enabling MMX if march passed a CPU that supported SSE. The exception to this is if you pass -march for a cpu supports SSE and also pass -mno-sse. We should still enable MMX since its part of the CPU capability.
1 parent a091f70 commit ba73aad

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,6 @@ bool X86TargetInfo::initFeatureMap(
131131
case CK_Lakemont:
132132
break;
133133

134-
case CK_PentiumMMX:
135-
case CK_Pentium2:
136-
case CK_K6:
137-
case CK_WinChipC6:
138-
setFeatureEnabledImpl(Features, "mmx", true);
139-
break;
140-
141134
case CK_Cooperlake:
142135
// CPX inherits all CLX features plus AVX512BF16
143136
setFeatureEnabledImpl(Features, "avx512bf16", true);
@@ -254,6 +247,12 @@ bool X86TargetInfo::initFeatureMap(
254247
case CK_C3_2:
255248
setFeatureEnabledImpl(Features, "sse", true);
256249
setFeatureEnabledImpl(Features, "fxsr", true);
250+
LLVM_FALLTHROUGH;
251+
case CK_PentiumMMX:
252+
case CK_Pentium2:
253+
case CK_K6:
254+
case CK_WinChipC6:
255+
setFeatureEnabledImpl(Features, "mmx", true);
257256
break;
258257

259258
case CK_Tremont:
@@ -291,6 +290,7 @@ bool X86TargetInfo::initFeatureMap(
291290
setFeatureEnabledImpl(Features, "fxsr", true);
292291
setFeatureEnabledImpl(Features, "cx16", true);
293292
setFeatureEnabledImpl(Features, "sahf", true);
293+
setFeatureEnabledImpl(Features, "mmx", true);
294294
break;
295295

296296
case CK_KNM:
@@ -321,6 +321,7 @@ bool X86TargetInfo::initFeatureMap(
321321
setFeatureEnabledImpl(Features, "xsave", true);
322322
setFeatureEnabledImpl(Features, "movbe", true);
323323
setFeatureEnabledImpl(Features, "sahf", true);
324+
setFeatureEnabledImpl(Features, "mmx", true);
324325
break;
325326

326327
case CK_K6_2:
@@ -369,6 +370,7 @@ bool X86TargetInfo::initFeatureMap(
369370
setFeatureEnabledImpl(Features, "cx16", true);
370371
setFeatureEnabledImpl(Features, "fxsr", true);
371372
setFeatureEnabledImpl(Features, "sahf", true);
373+
setFeatureEnabledImpl(Features, "mmx", true);
372374
break;
373375

374376
case CK_ZNVER2:
@@ -390,6 +392,7 @@ bool X86TargetInfo::initFeatureMap(
390392
setFeatureEnabledImpl(Features, "fsgsbase", true);
391393
setFeatureEnabledImpl(Features, "fxsr", true);
392394
setFeatureEnabledImpl(Features, "lzcnt", true);
395+
setFeatureEnabledImpl(Features, "mmx", true);
393396
setFeatureEnabledImpl(Features, "mwaitx", true);
394397
setFeatureEnabledImpl(Features, "movbe", true);
395398
setFeatureEnabledImpl(Features, "pclmul", true);
@@ -433,6 +436,7 @@ bool X86TargetInfo::initFeatureMap(
433436
setFeatureEnabledImpl(Features, "fxsr", true);
434437
setFeatureEnabledImpl(Features, "xsave", true);
435438
setFeatureEnabledImpl(Features, "sahf", true);
439+
setFeatureEnabledImpl(Features, "mmx", true);
436440
break;
437441
}
438442
if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec))

clang/test/Preprocessor/x86_target_features.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,26 @@
269269

270270
// NOSSE42POPCNT: #define __POPCNT__ 1
271271

272-
// RUN: %clang -target i386-unknown-unknown -march=atom -msse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSEMMX %s
272+
// RUN: %clang -target i386-unknown-unknown -march=pentium -msse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSEMMX %s
273273

274274
// SSEMMX: #define __MMX__ 1
275275

276-
// RUN: %clang -target i386-unknown-unknown -march=atom -msse -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSENOSSEMMX %s
276+
// RUN: %clang -target i386-unknown-unknown -march=pentium -msse -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSENOSSEMMX %s
277277

278278
// SSENOSSEMMX-NOT: #define __MMX__ 1
279279

280-
// RUN: %clang -target i386-unknown-unknown -march=atom -msse -mno-mmx -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSENOMMX %s
280+
// RUN: %clang -target i386-unknown-unknown -march=pentium -msse -mno-mmx -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSENOMMX %s
281281

282282
// SSENOMMX-NOT: #define __MMX__ 1
283283

284+
// RUN: %clang -target i386-unknown-unknown -march=pentium3 -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
285+
// RUN: %clang -target i386-unknown-unknown -march=atom -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
286+
// RUN: %clang -target i386-unknown-unknown -march=knl -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
287+
// RUN: %clang -target i386-unknown-unknown -march=btver1 -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
288+
// RUN: %clang -target i386-unknown-unknown -march=znver1 -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
289+
290+
// MARCHMMXNOSSE: #define __MMX__ 1
291+
284292
// RUN: %clang -target i386-unknown-unknown -march=atom -mf16c -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=F16C %s
285293

286294
// F16C: #define __AVX__ 1

0 commit comments

Comments
 (0)