mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201272 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1044,12 +1044,26 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
||||
TargetTransformInfo::OperandValueKind Op2VK =
|
||||
TargetTransformInfo::OK_UniformConstantValue;
|
||||
|
||||
// Check whether all second operands are constant.
|
||||
for (unsigned i = 0; i < VL.size(); ++i)
|
||||
if (!isa<ConstantInt>(cast<Instruction>(VL[i])->getOperand(1))) {
|
||||
// If all operands are exactly the same ConstantInt then set the
|
||||
// operand kind to OK_UniformConstantValue.
|
||||
// If instead not all operands are constants, then set the operand kind
|
||||
// to OK_AnyValue. If all operands are constants but not the same,
|
||||
// then set the operand kind to OK_NonUniformConstantValue.
|
||||
ConstantInt *CInt = NULL;
|
||||
for (unsigned i = 0; i < VL.size(); ++i) {
|
||||
const Instruction *I = cast<Instruction>(VL[i]);
|
||||
if (!isa<ConstantInt>(I->getOperand(1))) {
|
||||
Op2VK = TargetTransformInfo::OK_AnyValue;
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
CInt = cast<ConstantInt>(I->getOperand(1));
|
||||
continue;
|
||||
}
|
||||
if (Op2VK == TargetTransformInfo::OK_UniformConstantValue &&
|
||||
CInt != cast<ConstantInt>(I->getOperand(1)))
|
||||
Op2VK = TargetTransformInfo::OK_NonUniformConstantValue;
|
||||
}
|
||||
|
||||
ScalarCost =
|
||||
VecTy->getNumElements() *
|
||||
|
Reference in New Issue
Block a user