[clang] [X86][Driver] Do not add `-evex512` for `-march=native` when the target doesn't support AVX512 (PR #91694)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 9 20:27:14 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-driver
Author: Phoebe Wang (phoebewang)
<details>
<summary>Changes</summary>
Users want `-march=sandybridge -mavx512f -mavx512vl` behaves the same as `-march=native -mavx512f -mavx512vl` on a sandybridge target.
Fixes: #<!-- -->91076
---
Full diff: https://github.com/llvm/llvm-project/pull/91694.diff
1 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+6-2)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 53e26a9f8e229..c6d97ef4e971a 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -132,10 +132,14 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
if (StringRef(A->getValue()) == "native") {
llvm::StringMap<bool> HostFeatures;
- if (llvm::sys::getHostCPUFeatures(HostFeatures))
- for (auto &F : HostFeatures)
+ if (llvm::sys::getHostCPUFeatures(HostFeatures)) {
+ for (auto &F : HostFeatures) {
+ if (!F.second && F.first() == "evex512")
+ continue;
Features.push_back(
Args.MakeArgString((F.second ? "+" : "-") + F.first()));
+ }
+ }
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/91694
More information about the cfe-commits
mailing list