mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 06:24:57 +00:00
ARM cost model: Account for zero cost scalar SROA instructions
By vectorizing a series of srl, or, ... instructions we have obfuscated the intention so much that the backend does not know how to fold this code away. radar://15336950 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193573 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1013,9 +1013,24 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
||||
TTI->getCmpSelInstrCost(Opcode, ScalarTy, Builder.getInt1Ty());
|
||||
VecCost = TTI->getCmpSelInstrCost(Opcode, VecTy, MaskTy);
|
||||
} else {
|
||||
ScalarCost = VecTy->getNumElements() *
|
||||
TTI->getArithmeticInstrCost(Opcode, ScalarTy);
|
||||
VecCost = TTI->getArithmeticInstrCost(Opcode, VecTy);
|
||||
// Certain instructions can be cheaper to vectorize if they have a
|
||||
// constant second vector operand.
|
||||
TargetTransformInfo::OperandValueKind Op1VK =
|
||||
TargetTransformInfo::OK_AnyValue;
|
||||
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))) {
|
||||
Op2VK = TargetTransformInfo::OK_AnyValue;
|
||||
break;
|
||||
}
|
||||
|
||||
ScalarCost =
|
||||
VecTy->getNumElements() *
|
||||
TTI->getArithmeticInstrCost(Opcode, ScalarTy, Op1VK, Op2VK);
|
||||
VecCost = TTI->getArithmeticInstrCost(Opcode, VecTy, Op1VK, Op2VK);
|
||||
}
|
||||
return VecCost - ScalarCost;
|
||||
}
|
||||
|
Reference in New Issue
Block a user