[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.
This commit is contained in:
Craig Topper 2019-11-06 09:58:51 -08:00
parent a091f70610
commit ba73aad4f6
2 changed files with 22 additions and 10 deletions

View File

@ -131,13 +131,6 @@ bool X86TargetInfo::initFeatureMap(
case CK_Lakemont: case CK_Lakemont:
break; break;
case CK_PentiumMMX:
case CK_Pentium2:
case CK_K6:
case CK_WinChipC6:
setFeatureEnabledImpl(Features, "mmx", true);
break;
case CK_Cooperlake: case CK_Cooperlake:
// CPX inherits all CLX features plus AVX512BF16 // CPX inherits all CLX features plus AVX512BF16
setFeatureEnabledImpl(Features, "avx512bf16", true); setFeatureEnabledImpl(Features, "avx512bf16", true);
@ -254,6 +247,12 @@ SkylakeCommon:
case CK_C3_2: case CK_C3_2:
setFeatureEnabledImpl(Features, "sse", true); setFeatureEnabledImpl(Features, "sse", true);
setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "fxsr", true);
LLVM_FALLTHROUGH;
case CK_PentiumMMX:
case CK_Pentium2:
case CK_K6:
case CK_WinChipC6:
setFeatureEnabledImpl(Features, "mmx", true);
break; break;
case CK_Tremont: case CK_Tremont:
@ -291,6 +290,7 @@ SkylakeCommon:
setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "fxsr", true);
setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "cx16", true);
setFeatureEnabledImpl(Features, "sahf", true); setFeatureEnabledImpl(Features, "sahf", true);
setFeatureEnabledImpl(Features, "mmx", true);
break; break;
case CK_KNM: case CK_KNM:
@ -321,6 +321,7 @@ SkylakeCommon:
setFeatureEnabledImpl(Features, "xsave", true); setFeatureEnabledImpl(Features, "xsave", true);
setFeatureEnabledImpl(Features, "movbe", true); setFeatureEnabledImpl(Features, "movbe", true);
setFeatureEnabledImpl(Features, "sahf", true); setFeatureEnabledImpl(Features, "sahf", true);
setFeatureEnabledImpl(Features, "mmx", true);
break; break;
case CK_K6_2: case CK_K6_2:
@ -369,6 +370,7 @@ SkylakeCommon:
setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "cx16", true);
setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "fxsr", true);
setFeatureEnabledImpl(Features, "sahf", true); setFeatureEnabledImpl(Features, "sahf", true);
setFeatureEnabledImpl(Features, "mmx", true);
break; break;
case CK_ZNVER2: case CK_ZNVER2:
@ -390,6 +392,7 @@ SkylakeCommon:
setFeatureEnabledImpl(Features, "fsgsbase", true); setFeatureEnabledImpl(Features, "fsgsbase", true);
setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "fxsr", true);
setFeatureEnabledImpl(Features, "lzcnt", true); setFeatureEnabledImpl(Features, "lzcnt", true);
setFeatureEnabledImpl(Features, "mmx", true);
setFeatureEnabledImpl(Features, "mwaitx", true); setFeatureEnabledImpl(Features, "mwaitx", true);
setFeatureEnabledImpl(Features, "movbe", true); setFeatureEnabledImpl(Features, "movbe", true);
setFeatureEnabledImpl(Features, "pclmul", true); setFeatureEnabledImpl(Features, "pclmul", true);
@ -433,6 +436,7 @@ SkylakeCommon:
setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "fxsr", true);
setFeatureEnabledImpl(Features, "xsave", true); setFeatureEnabledImpl(Features, "xsave", true);
setFeatureEnabledImpl(Features, "sahf", true); setFeatureEnabledImpl(Features, "sahf", true);
setFeatureEnabledImpl(Features, "mmx", true);
break; break;
} }
if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec)) if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec))

View File

@ -269,18 +269,26 @@
// NOSSE42POPCNT: #define __POPCNT__ 1 // NOSSE42POPCNT: #define __POPCNT__ 1
// RUN: %clang -target i386-unknown-unknown -march=atom -msse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSEMMX %s // RUN: %clang -target i386-unknown-unknown -march=pentium -msse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=SSEMMX %s
// SSEMMX: #define __MMX__ 1 // SSEMMX: #define __MMX__ 1
// 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 // 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
// SSENOSSEMMX-NOT: #define __MMX__ 1 // SSENOSSEMMX-NOT: #define __MMX__ 1
// 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 // 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
// SSENOMMX-NOT: #define __MMX__ 1 // SSENOMMX-NOT: #define __MMX__ 1
// RUN: %clang -target i386-unknown-unknown -march=pentium3 -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
// RUN: %clang -target i386-unknown-unknown -march=atom -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
// RUN: %clang -target i386-unknown-unknown -march=knl -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
// RUN: %clang -target i386-unknown-unknown -march=btver1 -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
// RUN: %clang -target i386-unknown-unknown -march=znver1 -mno-sse -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MARCHMMXNOSSE %s
// MARCHMMXNOSSE: #define __MMX__ 1
// RUN: %clang -target i386-unknown-unknown -march=atom -mf16c -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=F16C %s // RUN: %clang -target i386-unknown-unknown -march=atom -mf16c -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=F16C %s
// F16C: #define __AVX__ 1 // F16C: #define __AVX__ 1