diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2014-02-12 23:43:47 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2014-02-12 23:43:47 +0000 |
commit | b7882b3bd11b46cca650e318bb7b921a1bfc8e21 (patch) | |
tree | 97a7fdb6b7e8ffe0337e7c9260cc03cb39f3c1b9 /llvm/lib/Analysis/CostModel.cpp | |
parent | 386d566395d90b01ddddf3d0ab219097cca8c37c (diff) | |
download | bcm5719-llvm-b7882b3bd11b46cca650e318bb7b921a1bfc8e21.tar.gz bcm5719-llvm-b7882b3bd11b46cca650e318bb7b921a1bfc8e21.zip |
[Vectorizer] Add a new 'OperandValueKind' in TargetTransformInfo called
'OK_NonUniformConstValue' to identify operands which are constants but
not constant splats.
The cost model now allows returning 'OK_NonUniformConstValue'
for non splat operands that are instances of ConstantVector or
ConstantDataVector.
With this change, targets are now able to compute different costs
for instructions with non-uniform constant operands.
For example, On X86 the cost of a vector shift may vary depending on whether
the second operand is a uniform or non-uniform constant.
This patch applies the following changes:
- The cost model computation now takes into account non-uniform constants;
- The cost of vector shift instructions has been improved in
X86TargetTransformInfo analysis pass;
- BBVectorize, SLPVectorizer and LoopVectorize now know how to distinguish
between non-uniform and uniform constant operands.
Added a new test to verify that the output of opt
'-cost-model -analyze' is valid in the following configurations: SSE2,
SSE4.1, AVX, AVX2.
llvm-svn: 201272
Diffstat (limited to 'llvm/lib/Analysis/CostModel.cpp')
-rw-r--r-- | llvm/lib/Analysis/CostModel.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/CostModel.cpp b/llvm/lib/Analysis/CostModel.cpp index 543977a376f..898da8d0e8d 100644 --- a/llvm/lib/Analysis/CostModel.cpp +++ b/llvm/lib/Analysis/CostModel.cpp @@ -98,15 +98,20 @@ static TargetTransformInfo::OperandValueKind getOperandInfo(Value *V) { TargetTransformInfo::OperandValueKind OpInfo = TargetTransformInfo::OK_AnyValue; - // Check for a splat of a constant. + // Check for a splat of a constant or for a non uniform vector of constants. ConstantDataVector *CDV = 0; - if ((CDV = dyn_cast<ConstantDataVector>(V))) + if ((CDV = dyn_cast<ConstantDataVector>(V))) { + OpInfo = TargetTransformInfo::OK_NonUniformConstantValue; if (CDV->getSplatValue() != NULL) OpInfo = TargetTransformInfo::OK_UniformConstantValue; + } + ConstantVector *CV = 0; - if ((CV = dyn_cast<ConstantVector>(V))) + if ((CV = dyn_cast<ConstantVector>(V))) { + OpInfo = TargetTransformInfo::OK_NonUniformConstantValue; if (CV->getSplatValue() != NULL) OpInfo = TargetTransformInfo::OK_UniformConstantValue; + } return OpInfo; } |