[clang] 20a60f4 - [X86] Explicitly add popcnt feature to Intel CPUs with SSE4.2 in the frontend.
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 28 11:07:19 PDT 2020
Author: Craig Topper
Date: 2020-06-28T11:06:40-07:00
New Revision: 20a60f46f505fc790e126b8b860c689870355f36
URL: https://github.com/llvm/llvm-project/commit/20a60f46f505fc790e126b8b860c689870355f36
DIFF: https://github.com/llvm/llvm-project/commit/20a60f46f505fc790e126b8b860c689870355f36.diff
LOG: [X86] Explicitly add popcnt feature to Intel CPUs with SSE4.2 in the frontend.
Previously we inferred it if sse4.2 ended up being enabled after
all feature processing. But writing -march=nehalem -mno-sse4.2
should have popcnt enabled.
Added:
Modified:
clang/lib/Basic/Targets/X86.cpp
clang/test/Preprocessor/x86_target_features.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 653db5e8b4ac..4b61f3c5536f 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -224,6 +224,7 @@ bool X86TargetInfo::initFeatureMap(
LLVM_FALLTHROUGH;
case CK_Nehalem:
setFeatureEnabledImpl(Features, "sse4.2", true);
+ setFeatureEnabledImpl(Features, "popcnt", true);
LLVM_FALLTHROUGH;
case CK_Penryn:
setFeatureEnabledImpl(Features, "sse4.1", true);
@@ -281,6 +282,7 @@ bool X86TargetInfo::initFeatureMap(
setFeatureEnabledImpl(Features, "rdrnd", true);
setFeatureEnabledImpl(Features, "pclmul", true);
setFeatureEnabledImpl(Features, "sse4.2", true);
+ setFeatureEnabledImpl(Features, "popcnt", true);
setFeatureEnabledImpl(Features, "prfchw", true);
LLVM_FALLTHROUGH;
case CK_Bonnell:
@@ -307,6 +309,7 @@ bool X86TargetInfo::initFeatureMap(
setFeatureEnabledImpl(Features, "rdseed", true);
setFeatureEnabledImpl(Features, "adx", true);
setFeatureEnabledImpl(Features, "lzcnt", true);
+ setFeatureEnabledImpl(Features, "popcnt", true);
setFeatureEnabledImpl(Features, "bmi", true);
setFeatureEnabledImpl(Features, "bmi2", true);
setFeatureEnabledImpl(Features, "fma", true);
diff --git a/clang/test/Preprocessor/x86_target_features.c b/clang/test/Preprocessor/x86_target_features.c
index dc7c8109b4da..4a46a131afa7 100644
--- a/clang/test/Preprocessor/x86_target_features.c
+++ b/clang/test/Preprocessor/x86_target_features.c
@@ -269,6 +269,12 @@
// NOSSE42POPCNT: #define __POPCNT__ 1
+// RUN: %clang -target i386-unknown-unknown -march=nehalem -mno-sse4.2 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=CPUPOPCNT %s
+// RUN: %clang -target i386-unknown-unknown -march=silvermont -mno-sse4.2 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=CPUPOPCNT %s
+// RUN: %clang -target i386-unknown-unknown -march=knl -mno-sse4.2 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=CPUPOPCNT %s
+
+// CPUPOPCNT: #define __POPCNT__ 1
+
// 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
More information about the cfe-commits
mailing list