-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[X86][clang-cl] Add CL option /vlen #166375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8266,6 +8266,37 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, | |
| << "/kernel"; | ||
| } | ||
|
|
||
| if (Args.hasArg(options::OPT__SLASH_vlen_default)) { | ||
| // Override /vlen= options. | ||
|
||
| for (const Arg *A : Args.filtered(options::OPT__SLASH_vlen)) | ||
| A->claim(); | ||
| // Nothing to do for AVX512F/AVX512. | ||
| } else if (const Arg *A = Args.getLastArg(options::OPT__SLASH_vlen)) { | ||
| StringRef VLen = A->getValue(); | ||
| llvm::SmallSet<std::string, 4> Arch512 = {"AVX512F", "AVX512"}; | ||
| llvm::SmallSet<std::string, 4> Arch256 = {"AVX", "AVX2"}; | ||
|
|
||
| StringRef Arch = Args.getLastArgValue(options::OPT__SLASH_arch); | ||
|
||
| if (Arch != "") { | ||
| if (VLen == "=512") { | ||
| if (Arch512.contains(Arch.str())) | ||
| CmdArgs.push_back("-mprefer-vector-width=512"); | ||
| else | ||
| D.Diag(diag::warn_drv_argument_not_allowed_with) | ||
| << "/vlen=512" << std::string("/arch:").append(Arch); | ||
| } else if (VLen == "=256") { | ||
| if (Arch512.contains(Arch.str())) | ||
| CmdArgs.push_back("-mprefer-vector-width=256"); | ||
| else if (!Arch256.contains(Arch.str())) | ||
| D.Diag(diag::warn_drv_argument_not_allowed_with) | ||
| << "/vlen=256" << std::string("/arch:").append(Arch); | ||
| } else { | ||
| D.Diag(diag::warn_drv_unknown_argument_clang_cl) | ||
| << std::string("/vlen").append(VLen); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg); | ||
| Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb); | ||
| if (MostGeneralArg && BestCaseArg) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,6 +133,27 @@ | |
| // tune: "-target-cpu" "sandybridge" | ||
| // tune-SAME: "-tune-cpu" "haswell" | ||
|
|
||
| // RUN: %clang_cl -m64 -arch:AVX512 -vlen=512 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=vlen512 %s | ||
| // vlen512: "-mprefer-vector-width=512" | ||
|
|
||
| // RUN: %clang_cl -m64 -arch:AVX512 -vlen=256 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=vlen256 %s | ||
| // vlen256: "-mprefer-vector-width=256" | ||
|
|
||
| // RUN: %clang_cl -m64 -arch:AVX512 -vlen=512 -vlen --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=noprefer %s | ||
|
||
| // noprefer-NOT: -mprefer-vector-width | ||
|
|
||
| // RUN: %clang_cl -m64 -arch:AVX2 -vlen=512 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx2vlen512 %s | ||
| // avx2vlen512: invalid argument '/vlen=512' not allowed with '/arch:AVX2' | ||
|
|
||
| // RUN: %clang_cl -m64 -arch:AVX2 -vlen=256 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx2vlen256 %s | ||
| // avx2vlen256-NOT: invalid argument | ||
|
|
||
| // RUN: %clang_cl -m32 -arch:SSE2 -vlen=256 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=sse2vlen256 %s | ||
| // sse2vlen256: invalid argument '/vlen=256' not allowed with '/arch:SSE2' | ||
|
|
||
| // RUN: %clang_cl -m64 -arch:AVX -vlen256 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avxvlen256 %s | ||
| // avxvlen256: unknown argument ignored in clang-cl: '/vlen256' | ||
|
|
||
| void f(void) { | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be
_SLASH_vlen(for the default) and_SLASH_vlen_EQfor the one ending in = (and that should be included in the flag spelling.But, since only two values are allowed, it might be simpler to do something like:
Does Clang provide good diagnostics when passing an
-mprefer-vector-widththat doesn't fit the target architecture?If so, could we make
_SLASH_vlen_EQ_256an alias for-mprefer-vector-width=256and so on, and not have to add any new driver logic at all?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! No, unfortunately: https://godbolt.org/z/hhvjP8W34