mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Add support to BBVectorize for vectorizing selects.
llvm-svn: 154700
This commit is contained in:
parent
6c3fc0ca53
commit
12b4c41203
@ -43,6 +43,9 @@ struct VectorizeConfig {
|
||||
/// @brief Vectorize the fused-multiply-add intrinsic.
|
||||
bool VectorizeFMA;
|
||||
|
||||
/// @brief Vectorize select instructions.
|
||||
bool VectorizeSelect;
|
||||
|
||||
/// @brief Vectorize loads and stores.
|
||||
bool VectorizeMemOps;
|
||||
|
||||
|
@ -95,6 +95,10 @@ static cl::opt<bool>
|
||||
NoFMA("bb-vectorize-no-fma", cl::init(false), cl::Hidden,
|
||||
cl::desc("Don't try to vectorize the fused-multiply-add intrinsic"));
|
||||
|
||||
static cl::opt<bool>
|
||||
NoSelect("bb-vectorize-no-select", cl::init(false), cl::Hidden,
|
||||
cl::desc("Don't try to vectorize select instructions"));
|
||||
|
||||
static cl::opt<bool>
|
||||
NoMemOps("bb-vectorize-no-mem-ops", cl::init(false), cl::Hidden,
|
||||
cl::desc("Don't try to vectorize loads and stores"));
|
||||
@ -552,6 +556,9 @@ namespace {
|
||||
Type *DestTy = C->getDestTy();
|
||||
if (!DestTy->isSingleValueType() || DestTy->isPointerTy())
|
||||
return false;
|
||||
} else if (isa<SelectInst>(I)) {
|
||||
if (!Config.VectorizeSelect)
|
||||
return false;
|
||||
} else if (!(I->isBinaryOp() || isa<ShuffleVectorInst>(I) ||
|
||||
isa<ExtractElementInst>(I) || isa<InsertElementInst>(I))) {
|
||||
return false;
|
||||
@ -1894,6 +1901,7 @@ VectorizeConfig::VectorizeConfig() {
|
||||
VectorizeCasts = !::NoCasts;
|
||||
VectorizeMath = !::NoMath;
|
||||
VectorizeFMA = !::NoFMA;
|
||||
VectorizeSelect = !::NoSelect;
|
||||
VectorizeMemOps = !::NoMemOps;
|
||||
AlignedOnly = ::AlignedOnly;
|
||||
ReqChainDepth= ::ReqChainDepth;
|
||||
|
30
test/Transforms/BBVectorize/simple-sel.ll
Normal file
30
test/Transforms/BBVectorize/simple-sel.ll
Normal file
@ -0,0 +1,30 @@
|
||||
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
|
||||
|
||||
; Basic depth-3 chain with select
|
||||
define double @test1(double %A1, double %A2, double %B1, double %B2, i1 %C1, i1 %C2) {
|
||||
; CHECK: @test1
|
||||
; 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
|
||||
; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1
|
||||
%X1 = fsub double %A1, %B1
|
||||
%X2 = fsub double %A2, %B2
|
||||
; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2
|
||||
%Y1 = fmul double %X1, %A1
|
||||
%Y2 = fmul double %X2, %A2
|
||||
; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2
|
||||
%Z1 = select i1 %C1, double %Y1, double %B1
|
||||
%Z2 = select i1 %C2, double %Y2, double %B2
|
||||
; CHECK: %Z1.v.i0.1 = insertelement <2 x i1> undef, i1 %C1, i32 0
|
||||
; CHECK: %Z1.v.i0.2 = insertelement <2 x i1> %Z1.v.i0.1, i1 %C2, i32 1
|
||||
; CHECK: %Z1 = select <2 x i1> %Z1.v.i0.2, <2 x double> %Y1, <2 x double> %X1.v.i1.2
|
||||
%R = fmul double %Z1, %Z2
|
||||
; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0
|
||||
; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1
|
||||
; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2
|
||||
ret double %R
|
||||
; CHECK: ret double %R
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user