summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Targets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r--clang/lib/Basic/Targets.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 64b00d7fae3..665f1016334 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -2133,7 +2133,7 @@ void X86TargetInfo::setSSELevel(llvm::StringMap<bool> &Features,
case AVX:
Features["avx"] = true;
case SSE42:
- Features["popcnt"] = Features["sse4.2"] = true;
+ Features["sse4.2"] = true;
case SSE41:
Features["sse4.1"] = true;
case SSSE3:
@@ -2166,7 +2166,7 @@ void X86TargetInfo::setSSELevel(llvm::StringMap<bool> &Features,
case SSE41:
Features["sse4.1"] = false;
case SSE42:
- Features["popcnt"] = Features["sse4.2"] = false;
+ Features["sse4.2"] = false;
case AVX:
Features["fma"] = Features["avx"] = false;
setXOPLevel(Features, FMA4, false);
@@ -2406,6 +2406,15 @@ bool X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features,
XOPLevel = std::max(XOPLevel, XLevel);
}
+ // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
+ // Can't do this earlier because we need to be able to explicitly enable
+ // popcnt and still disable sse4.2.
+ if (!HasPOPCNT && SSELevel >= SSE42 &&
+ std::find(Features.begin(), Features.end(), "-popcnt") == Features.end()){
+ HasPOPCNT = true;
+ Features.push_back("+popcnt");
+ }
+
// LLVM doesn't have a separate switch for fpmath, so only accept it if it
// matches the selected sse level.
if (FPMath == FP_SSE && SSELevel < SSE1) {
OpenPOWER on IntegriCloud