From 443c999c967d555f6942834b0924c60226b3e6f2 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Tue, 11 Dec 2012 19:59:32 +0000 Subject: [PATCH] Add -fslp-vectorize to enable bb-vectorize Add -fslp-vectorize (with -ftree-slp-vectorize as an alias for gcc compatibility) to provide a way to enable the basic-block vectorization pass. This uses the same acronym as gcc, superword-level parallelism (SLP), also common in the literature, to refer to basic-block vectorization. Nadav suggested this as a follow-up to the adding of -fvectorize. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169909 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 5 +++++ lib/Driver/Tools.cpp | 7 +++++++ test/Driver/clang_f_opts.c | 13 +++++++++++++ 3 files changed, 25 insertions(+) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index c3edfe3198..759864369c 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -655,6 +655,11 @@ def fvectorize : Flag<["-"], "fvectorize">, Group, def fno_vectorize : Flag<["-"], "fno-vectorize">, Group; def ftree_vectorize : Flag<["-"], "ftree-vectorize">, Alias; def fno_tree_vectorize : Flag<["-"], "fno-tree-vectorize">, Alias; +def fslp_vectorize : Flag<["-"], "fslp-vectorize">, Group, + HelpText<"Enable the superword-level parallelism vectorization passes">; +def fno_slp_vectorize : Flag<["-"], "fno-slp-vectorize">, Group; +def ftree_slp_vectorize : Flag<["-"], "ftree-slp-vectorize">, Alias; +def fno_tree_slp_vectorize : Flag<["-"], "fno-tree-slp-vectorize">, Alias; def Wlarge_by_value_copy_def : Flag<["-"], "Wlarge-by-value-copy">, HelpText<"Warn if a function definition returns or accepts an object larger " "in bytes than a given value">, Flags<[HelpHidden]>; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 9ae03fc8c6..25aab58660 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2935,6 +2935,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-vectorize-loops"); } + // -fno-slp-vectorize is default. + if (Args.hasFlag(options::OPT_fslp_vectorize, + options::OPT_fno_slp_vectorize, false)) { + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-vectorize"); + } + if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ)) A->render(Args, CmdArgs); diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index 8ab7c04147..6fc9239ce5 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -51,3 +51,16 @@ // CHECK-VECTORIZE: "-vectorize-loops" // CHECK-NO-VECTORIZE-NOT: "-backend-option" // CHECK-NO-VECTORIZE-NOT: "-vectorize-loops" + +// RUN: %clang -### -S -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s +// RUN: %clang -### -S -fno-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s +// RUN: %clang -### -S -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s +// RUN: %clang -### -S -fslp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s +// RUN: %clang -### -S -ftree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s +// RUN: %clang -### -S -ftree-no-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s +// RUN: %clang -### -S -ftree-no-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s +// RUN: %clang -### -S -ftree-slp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s +// CHECK-SLP-VECTORIZE: "-backend-option" +// CHECK-SLP-VECTORIZE: "-vectorize" +// CHECK-NO-SLP-VECTORIZE-NOT: "-backend-option" +// CHECK-NO-SLP-VECTORIZE-NOT: "-vectorize" -- 2.40.0