Disable loop vectorizer unrolling when no unrolling requested

In addition to the regular loop unrolling transformation, the loop vectorizer
can also unroll loops. If no unrolling has specifically been requested (by
-fno-unroll-loops), and the loop vectorizer will be used, then add the backend
option to (also) prevent the loop vectorizer from unrolling loops.

I confirmed with Nadav (off list) that disabling vectorizer loop unrolling when
-fno-unroll-loops is provided is the desired behavior.

llvm-svn: 189440
This commit is contained in:
Hal Finkel 2013-08-28 04:40:22 +00:00
parent 62caa709fe
commit 7d0867f48c
2 changed files with 14 additions and 1 deletions

View File

@ -3382,9 +3382,19 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
OptSpecifier VectorizeAliasOption = EnableVec ? options::OPT_O_Group :
options::OPT_fvectorize;
if (Args.hasFlag(options::OPT_fvectorize, VectorizeAliasOption,
options::OPT_fno_vectorize, EnableVec))
options::OPT_fno_vectorize, EnableVec)) {
CmdArgs.push_back("-vectorize-loops");
// In addition to the regular loop unrolling transformation, the loop
// vectorizer can also unroll loops. If no unrolling has specifically been
// requested, then also prevent the loop vectorizer from unrolling loops.
if (Args.hasFlag(options::OPT_fno_unroll_loops,
options::OPT_funroll_loops, false)) {
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-force-vector-unroll=1");
}
}
// -fslp-vectorize is default.
if (Args.hasFlag(options::OPT_fslp_vectorize,
options::OPT_fno_slp_vectorize, true))

View File

@ -45,6 +45,7 @@
// CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"
// RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
// RUN: %clang -### -S -fvectorize -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE-NO-UNROLL %s
// RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
// RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
// RUN: %clang -### -S -fvectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
@ -65,6 +66,8 @@
// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
// CHECK-VECTORIZE: "-vectorize-loops"
// CHECK-NO-VECTORIZE-NOT: "-vectorize-loops"
// CHECK-VECTORIZE-NOT: "-backend-option" "-force-vector-unroll=1"
// CHECK-VECTORIZE-NO-UNROLL: "-backend-option" "-force-vector-unroll=1"
// 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