aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2012-06-24 13:28:01 +0000
committerHal Finkel <hfinkel@anl.gov>2012-06-24 13:28:01 +0000
commit768edf3cd037aab10391abc279f71470df8e3156 (patch)
tree85075e1cb344f47ab0c1a1fe90e3777836b1aa14
parentedb5842b7cf53ba4a4b5d3e1bad49a9fad47c02b (diff)
downloadexternal_llvm-768edf3cd037aab10391abc279f71470df8e3156.zip
external_llvm-768edf3cd037aab10391abc279f71470df8e3156.tar.gz
external_llvm-768edf3cd037aab10391abc279f71470df8e3156.tar.bz2
Allow controlling vectorization of boolean values separately from other integer types.
These are used as the result of comparisons, and often handled differently from larger integer types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159111 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Transforms/Vectorize.h3
-rw-r--r--lib/Transforms/Vectorize/BBVectorize.cpp18
-rw-r--r--test/Transforms/BBVectorize/simple-sel.ll3
3 files changed, 20 insertions, 4 deletions
diff --git a/include/llvm/Transforms/Vectorize.h b/include/llvm/Transforms/Vectorize.h
index d73db66..953bf86 100644
--- a/include/llvm/Transforms/Vectorize.h
+++ b/include/llvm/Transforms/Vectorize.h
@@ -28,6 +28,9 @@ struct VectorizeConfig {
/// @brief The size of the native vector registers.
unsigned VectorBits;
+ /// @brief Vectorize boolean values.
+ bool VectorizeBools;
+
/// @brief Vectorize integer values.
bool VectorizeInts;
diff --git a/lib/Transforms/Vectorize/BBVectorize.cpp b/lib/Transforms/Vectorize/BBVectorize.cpp
index 55e0da7..8518731 100644
--- a/lib/Transforms/Vectorize/BBVectorize.cpp
+++ b/lib/Transforms/Vectorize/BBVectorize.cpp
@@ -77,6 +77,10 @@ MaxCandPairsForCycleCheck("bb-vectorize-max-cycle-check-pairs", cl::init(200),
" a full cycle check"));
static cl::opt<bool>
+NoBools("bb-vectorize-no-bools", cl::init(false), cl::Hidden,
+ cl::desc("Don't try to vectorize boolean (i1) values"));
+
+static cl::opt<bool>
NoInts("bb-vectorize-no-ints", cl::init(false), cl::Hidden,
cl::desc("Don't try to vectorize integer values"));
@@ -614,10 +618,15 @@ namespace {
!(VectorType::isValidElementType(T2) || T2->isVectorTy()))
return false;
- if (!Config.VectorizeInts
- && (T1->isIntOrIntVectorTy() || T2->isIntOrIntVectorTy()))
- return false;
-
+ if (T1->getScalarSizeInBits() == 1 && T2->getScalarSizeInBits() == 1) {
+ if (!Config.VectorizeBools)
+ return false;
+ } else {
+ if (!Config.VectorizeInts
+ && (T1->isIntOrIntVectorTy() || T2->isIntOrIntVectorTy()))
+ return false;
+ }
+
if (!Config.VectorizeFloats
&& (T1->isFPOrFPVectorTy() || T2->isFPOrFPVectorTy()))
return false;
@@ -1990,6 +1999,7 @@ llvm::vectorizeBasicBlock(Pass *P, BasicBlock &BB, const VectorizeConfig &C) {
//===----------------------------------------------------------------------===//
VectorizeConfig::VectorizeConfig() {
VectorBits = ::VectorBits;
+ VectorizeBools = !::NoBools;
VectorizeInts = !::NoInts;
VectorizeFloats = !::NoFloats;
VectorizePointers = !::NoPointers;
diff --git a/test/Transforms/BBVectorize/simple-sel.ll b/test/Transforms/BBVectorize/simple-sel.ll
index 7fb9c8b..325792a 100644
--- a/test/Transforms/BBVectorize/simple-sel.ll
+++ b/test/Transforms/BBVectorize/simple-sel.ll
@@ -1,5 +1,6 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s
+; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-no-bools -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-NB
; Basic depth-3 chain with select
define double @test1(double %A1, double %A2, double %B1, double %B2, i1 %C1, i1 %C2) {
@@ -30,6 +31,7 @@ define double @test1(double %A1, double %A2, double %B1, double %B2, i1 %C1, i1
; Basic depth-3 chain with select (and vect. compare)
define double @test2(double %A1, double %A2, double %B1, double %B2) {
; CHECK: @test2
+; CHECK-NB: @test2
; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
@@ -43,6 +45,7 @@ define double @test2(double %A1, double %A2, double %B1, double %B2) {
%C1 = fcmp ogt double %X1, %A1
%C2 = fcmp ogt double %X2, %A2
; CHECK: %C1 = fcmp ogt <2 x double> %X1, %X1.v.i0.2
+; CHECK-NB: fcmp ogt double
%Z1 = select i1 %C1, double %Y1, double %B1
%Z2 = select i1 %C2, double %Y2, double %B2
; CHECK: %Z1 = select <2 x i1> %C1, <2 x double> %Y1, <2 x double> %X1.v.i1.2