[clang] [X86][Driver] Do not add `-evex512` for `-march=native` when the targ… (PR #91694)
Phoebe Wang via cfe-commits
cfe-commits at lists.llvm.org
Thu May 9 20:26:45 PDT 2024
https://github.com/phoebewang created https://github.com/llvm/llvm-project/pull/91694
…et doesn't support AVX512
Users want `-march=sandybridge -mavx512f -mavx512vl` behaves the same as `-march=native -mavx512f -mavx512vl` on a sandybridge target.
Fixes: #91076
>From 6ea15aa0ee6726cad8dccff10155f058afa0f013 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Fri, 10 May 2024 11:21:41 +0800
Subject: [PATCH] [X86][Driver] Do not add `-evex512` for `-march=native` when
the target doesn't support AVX512
Users want `-march=sandybridge -mavx512f -mavx512vl` behaves the same as
`-march=native -mavx512f -mavx512vl` on a sandybridge target.
Fixes: #91076
---
clang/lib/Driver/ToolChains/Arch/X86.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
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()));
+ }
+ }
}
}
More information about the cfe-commits
mailing list