]> granicus.if.org Git - clang/commitdiff
[Hexagon] Enable auto-vectorization only when -fvectorize was given
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Thu, 12 Apr 2018 16:25:35 +0000 (16:25 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Thu, 12 Apr 2018 16:25:35 +0000 (16:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329923 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Hexagon.cpp
test/Driver/hexagon-vectorize.c [new file with mode: 0644]

index 25a911f4b2c09aee2620396809bfe1d51a21e51c..6402a8288ba9e5f740fedf52b736f683dc4d6f6a 100644 (file)
@@ -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 (file)
index 0000000..d6a537e
--- /dev/null
@@ -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