Skip to content

Commit 266f047

Browse files
committed
Address review comments
1 parent bdecf07 commit 266f047

File tree

3 files changed

+23
-30
lines changed

3 files changed

+23
-30
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9218,10 +9218,12 @@ def : CLFlag<"Qscatter-">, Alias<mno_scatter>,
92189218

92199219
def _SLASH_arch : CLCompileJoined<"arch:">,
92209220
HelpText<"Set architecture for code generation">;
9221-
def _SLASH_vlen : CLCompileJoined<"vlen">,
9222-
HelpText<"Set vector length for autovectorization and other optimizations">;
9223-
def _SLASH_vlen_default : CLFlag<"vlen">,
9221+
def _SLASH_vlen : CLFlag<"vlen">,
92249222
HelpText<"Set default vector length for autovectorization and other optimizations">;
9223+
def _SLASH_vlen_EQ_256 : CLFlag<"vlen=256">,
9224+
HelpText<"Set vector length of 256 bits for autovectorization and other optimizations">;
9225+
def _SLASH_vlen_EQ_512 : CLFlag<"vlen=512">,
9226+
HelpText<"Set vector length of 512 bits for autovectorization and other optimizations">;
92259227

92269228
def _SLASH_M_Group : OptionGroup<"</M group>">, Group<cl_compile_Group>;
92279229
def _SLASH_volatile_Group : OptionGroup<"</volatile group>">,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8266,34 +8266,28 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
82668266
<< "/kernel";
82678267
}
82688268

8269-
if (Args.hasArg(options::OPT__SLASH_vlen_default)) {
8270-
// Override /vlen= options.
8271-
for (const Arg *A : Args.filtered(options::OPT__SLASH_vlen))
8272-
A->claim();
8273-
// Nothing to do for AVX512F/AVX512.
8274-
} else if (const Arg *A = Args.getLastArg(options::OPT__SLASH_vlen)) {
8275-
StringRef VLen = A->getValue();
8269+
if (const Arg *A = Args.getLastArg(options::OPT__SLASH_vlen,
8270+
options::OPT__SLASH_vlen_EQ_256,
8271+
options::OPT__SLASH_vlen_EQ_512)) {
82768272
llvm::SmallSet<std::string, 4> Arch512 = {"AVX512F", "AVX512"};
82778273
llvm::SmallSet<std::string, 4> Arch256 = {"AVX", "AVX2"};
82788274

82798275
StringRef Arch = Args.getLastArgValue(options::OPT__SLASH_arch);
8280-
if (Arch != "") {
8281-
if (VLen == "=512") {
8282-
if (Arch512.contains(Arch.str()))
8283-
CmdArgs.push_back("-mprefer-vector-width=512");
8284-
else
8285-
D.Diag(diag::warn_drv_argument_not_allowed_with)
8286-
<< "/vlen=512" << std::string("/arch:").append(Arch);
8287-
} else if (VLen == "=256") {
8288-
if (Arch512.contains(Arch.str()))
8289-
CmdArgs.push_back("-mprefer-vector-width=256");
8290-
else if (!Arch256.contains(Arch.str()))
8291-
D.Diag(diag::warn_drv_argument_not_allowed_with)
8292-
<< "/vlen=256" << std::string("/arch:").append(Arch);
8293-
} else {
8294-
D.Diag(diag::warn_drv_unknown_argument_clang_cl)
8295-
<< std::string("/vlen").append(VLen);
8296-
}
8276+
8277+
if (A->getOption().matches(options::OPT__SLASH_vlen_EQ_512)) {
8278+
if (Arch512.contains(Arch.str()))
8279+
CmdArgs.push_back("-mprefer-vector-width=512");
8280+
else
8281+
D.Diag(diag::warn_drv_argument_not_allowed_with)
8282+
<< "/vlen=512" << std::string("/arch:").append(Arch);
8283+
}
8284+
8285+
if (A->getOption().matches(options::OPT__SLASH_vlen_EQ_256)) {
8286+
if (Arch512.contains(Arch.str()))
8287+
CmdArgs.push_back("-mprefer-vector-width=256");
8288+
else if (!Arch256.contains(Arch.str()))
8289+
D.Diag(diag::warn_drv_argument_not_allowed_with)
8290+
<< "/vlen=256" << std::string("/arch:").append(Arch);
82978291
}
82988292
}
82998293

clang/test/Driver/cl-x86-flags.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@
151151
// RUN: %clang_cl -m32 -arch:SSE2 -vlen=256 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=sse2vlen256 %s
152152
// sse2vlen256: invalid argument '/vlen=256' not allowed with '/arch:SSE2'
153153

154-
// RUN: %clang_cl -m64 -arch:AVX -vlen256 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avxvlen256 %s
155-
// avxvlen256: unknown argument ignored in clang-cl: '/vlen256'
156-
157154
void f(void) {
158155
}
159156

0 commit comments

Comments
 (0)