[PATCH] [X86] Use sys::getHostCPUFeatures to improve -march=native
Eric Christopher
echristo at gmail.com
Mon Mar 30 09:07:35 PDT 2015
I think this should be ok. It'll turn some "hidden" features that would
have been "target-cpu" features into "target-features" features explicitly,
but that'll just mean wordier attribute descriptions (and will be more
accurate).
-eric
On Sun, Mar 29, 2015 at 9:16 PM Craig Topper <craig.topper at gmail.com> wrote:
> Hi chandlerc, echristo, rafael, grosbach,
>
> Some versions of Sandybridge, Ivybridge, Haswell, and Broadwell CPUs don't
> support AVX. Currently, getHostCPUName changes the CPU name to Nehalem when
> it detects one of the CPUs. This also ends up disabling other features that
> these CPUs might still have as well as changing the scheduling model, etc.
>
> This patch attempts to correct this by allowing the CPU name to work
> unaltered and then use getHostCPUFeatures to explicitly specify which
> features are enabled and disabled.
>
> Similar patch will also be made to llc.
>
> http://reviews.llvm.org/D8694
>
> Files:
> lib/Driver/Tools.cpp
>
> Index: lib/Driver/Tools.cpp
> ===================================================================
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -1566,6 +1566,17 @@
> static void getX86TargetFeatures(const Driver &D, const llvm::Triple
> &Triple,
> const ArgList &Args,
> std::vector<const char *> &Features) {
> + // If -march=native, autodetect the feature list.
> + if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
> + if (StringRef(A->getValue()) == "native") {
> + llvm::StringMap<bool> HostFeatures;
> + if (llvm::sys::getHostCPUFeatures(HostFeatures))
> + for (auto &F : HostFeatures)
> + Features.push_back(Args.MakeArgString((F.second ? "+" : "-") +
> + F.first()));
> + }
> + }
> +
> if (Triple.getArchName() == "x86_64h") {
> // x86_64h implies quite a few of the more modern subtarget features
> // for Haswell class CPUs, but not all of them. Opt-out of a few.
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150330/5d9ad205/attachment.html>
More information about the cfe-commits
mailing list