Revert "[LV] Extend trunc optimization to all IVs with constant integer steps"

This reverts commit r294967. This patch caused execution time slowdowns in a
few LLVM test-suite tests, as reported by the clang-cmake-aarch64-quick bot.
I'm reverting to investigate.

llvm-svn: 294973
This commit is contained in:
Matthew Simpson
2017-02-13 18:02:35 +00:00
parent 58a221a4e2
commit 659f92e2aa
3 changed files with 14 additions and 54 deletions

View File

@@ -4879,15 +4879,12 @@ void InnerLoopVectorizer::vectorizeBlockInLoop(BasicBlock *BB, PhiVector *PV) {
// induction variable. Notice that we can only optimize the 'trunc' case
// because (a) FP conversions lose precision, (b) sext/zext may wrap, and
// (c) other casts depend on pointer size.
if (auto *Trunc = dyn_cast<TruncInst>(CI))
if (auto *Phi = dyn_cast<PHINode>(Trunc->getOperand(0))) {
auto II = Legal->getInductionVars()->find(Phi);
if (II != Legal->getInductionVars()->end())
if (II->second.getConstIntStepValue()) {
widenIntInduction(Phi, Trunc);
break;
}
}
auto ID = Legal->getInductionVars()->lookup(OldInduction);
if (isa<TruncInst>(CI) && CI->getOperand(0) == OldInduction &&
ID.getConstIntStepValue()) {
widenIntInduction(OldInduction, cast<TruncInst>(CI));
break;
}
/// Vectorize casts.
Type *DestTy =
@@ -7227,17 +7224,12 @@ unsigned LoopVectorizationCostModel::getInstructionCost(Instruction *I,
case Instruction::Trunc:
case Instruction::FPTrunc:
case Instruction::BitCast: {
// We optimize the truncation of induction variables having constant
// integer steps. The cost of these truncations is the same as the scalar
// operation.
if (auto *Trunc = dyn_cast<TruncInst>(I))
if (auto *Phi = dyn_cast<PHINode>(Trunc->getOperand(0))) {
auto II = Legal->getInductionVars()->find(Phi);
if (II != Legal->getInductionVars()->end())
if (II->second.getConstIntStepValue())
return TTI.getCastInstrCost(Instruction::Trunc, Trunc->getDestTy(),
Trunc->getSrcTy());
}
// We optimize the truncation of induction variable.
// The cost of these is the same as the scalar operation.
if (I->getOpcode() == Instruction::Trunc &&
Legal->isInductionVariable(I->getOperand(0)))
return TTI.getCastInstrCost(I->getOpcode(), I->getType(),
I->getOperand(0)->getType());
Type *SrcScalarTy = I->getOperand(0)->getType();
Type *SrcVecTy = ToVectorTy(SrcScalarTy, VF);