From bce9a77afa563a68293430829f66e73dc3ba406a Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 12 Apr 2018 16:25:35 +0000 Subject: [PATCH] [Hexagon] Enable auto-vectorization only when -fvectorize was given git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329923 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains/Hexagon.cpp | 7 +++++++ test/Driver/hexagon-vectorize.c | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 test/Driver/hexagon-vectorize.c diff --git a/lib/Driver/ToolChains/Hexagon.cpp b/lib/Driver/ToolChains/Hexagon.cpp index 25a911f4b2..6402a8288b 100644 --- a/lib/Driver/ToolChains/Hexagon.cpp +++ b/lib/Driver/ToolChains/Hexagon.cpp @@ -520,6 +520,13 @@ void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs, CC1Args.push_back("-target-feature"); CC1Args.push_back("+reserved-r19"); } + if (Arg *A = DriverArgs.getLastArg(options::OPT_fvectorize, + options::OPT_fno_vectorize)) { + if (A->getOption().matches(options::OPT_fvectorize)) { + CC1Args.push_back("-mllvm"); + CC1Args.push_back("-hexagon-autohvx"); + } + } } void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs, diff --git a/test/Driver/hexagon-vectorize.c b/test/Driver/hexagon-vectorize.c new file mode 100644 index 0000000000..d6a537ee8c --- /dev/null +++ b/test/Driver/hexagon-vectorize.c @@ -0,0 +1,7 @@ +// RUN: %clang -target hexagon -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT +// RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-VECTOR +// RUN: %clang -target hexagon -fvectorize -fno-vectorize -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOVECTOR + +// CHECK-DEFAULT-NOT: hexagon-autohvx +// CHECK-VECTOR: "-mllvm" "-hexagon-autohvx" +// CHECK-NOVECTOR-NOT: hexagon-autohvx -- 2.40.0