Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -4690,6 +4690,8 @@ def _SLASH_arch : CLCompileJoined<"arch:">, HelpText<"Set architecture for code generation">; +def _SLASH_tune : CLCompileJoined<"tune:">, + HelpText<"Set CPU for optimization without affecting instruction set">; def _SLASH_M_Group : OptionGroup<"">, Group; def _SLASH_volatile_Group : OptionGroup<"">, Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2080,8 +2080,9 @@ if (!Args.hasArg(clang::driver::options::OPT_march_EQ)) TuneCPU = "generic"; - // Override based on -mtune. - if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) { + // Override based on -mtune or /tune: + if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ, + clang::driver::options::OPT__SLASH_tune)) { StringRef Name = A->getValue(); if (Name == "native") { Index: clang/test/Driver/cl-x86-flags.c =================================================================== --- clang/test/Driver/cl-x86-flags.c +++ clang/test/Driver/cl-x86-flags.c @@ -128,5 +128,9 @@ // RUN: %clang_cl -m64 -arch:avx512 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx51264 %s // avx51264: argument unused during compilation +// RUN: %clang_cl -m64 -arch:AVX -tune:haswell --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=tune %s +// tune: "-target-cpu" "sandybridge" +// tune-SAME: "-tune-cpu" "haswell" + void f() { }