mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
[SLP] Dump Tree costs. NFC.
This adds LLVM_DEBUG messages to dump the (intermediate) tree cost calculations, which is useful to trace and see how the final cost is calculated.
This commit is contained in:
parent
1ebb153694
commit
ca45aad56d
@ -1744,6 +1744,19 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void dumpTreeCosts(TreeEntry *E, int ReuseShuffleCost, int VecCost,
|
||||||
|
int ScalarCost) const {
|
||||||
|
dbgs() << "SLP: Calculated costs for Tree:\n"; E->dump();
|
||||||
|
dbgs() << "SLP: Costs:\n";
|
||||||
|
dbgs() << "SLP: ReuseShuffleCost = " << ReuseShuffleCost << "\n";
|
||||||
|
dbgs() << "SLP: VectorCost = " << VecCost << "\n";
|
||||||
|
dbgs() << "SLP: ScalarCost = " << ScalarCost << "\n";
|
||||||
|
dbgs() << "SLP: ReuseShuffleCost + VecCost - ScalarCost = " <<
|
||||||
|
ReuseShuffleCost + VecCost - ScalarCost << "\n";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Create a new VectorizableTree entry.
|
/// Create a new VectorizableTree entry.
|
||||||
TreeEntry *newTreeEntry(ArrayRef<Value *> VL, Optional<ScheduleData *> Bundle,
|
TreeEntry *newTreeEntry(ArrayRef<Value *> VL, Optional<ScheduleData *> Bundle,
|
||||||
const InstructionsState &S,
|
const InstructionsState &S,
|
||||||
@ -3562,6 +3575,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
|||||||
TTI->getCastInstrCost(E->getOpcode(), VecTy, SrcVecTy,
|
TTI->getCastInstrCost(E->getOpcode(), VecTy, SrcVecTy,
|
||||||
TTI::getCastContextHint(VL0), CostKind, VL0);
|
TTI::getCastContextHint(VL0), CostKind, VL0);
|
||||||
}
|
}
|
||||||
|
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecCost, ScalarCost));
|
||||||
return VecCost - ScalarCost;
|
return VecCost - ScalarCost;
|
||||||
}
|
}
|
||||||
case Instruction::FCmp:
|
case Instruction::FCmp:
|
||||||
@ -3612,6 +3626,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
|||||||
CmpInst::BAD_ICMP_PREDICATE, CostKind);
|
CmpInst::BAD_ICMP_PREDICATE, CostKind);
|
||||||
VecCost = std::min(VecCost, IntrinsicCost);
|
VecCost = std::min(VecCost, IntrinsicCost);
|
||||||
}
|
}
|
||||||
|
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecCost, ScalarCost));
|
||||||
return ReuseShuffleCost + VecCost - ScalarCost;
|
return ReuseShuffleCost + VecCost - ScalarCost;
|
||||||
}
|
}
|
||||||
case Instruction::FNeg:
|
case Instruction::FNeg:
|
||||||
@ -3681,6 +3696,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
|||||||
int VecCost = TTI->getArithmeticInstrCost(
|
int VecCost = TTI->getArithmeticInstrCost(
|
||||||
E->getOpcode(), VecTy, CostKind, Op1VK, Op2VK, Op1VP, Op2VP,
|
E->getOpcode(), VecTy, CostKind, Op1VK, Op2VK, Op1VP, Op2VP,
|
||||||
Operands, VL0);
|
Operands, VL0);
|
||||||
|
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecCost, ScalarCost));
|
||||||
return ReuseShuffleCost + VecCost - ScalarCost;
|
return ReuseShuffleCost + VecCost - ScalarCost;
|
||||||
}
|
}
|
||||||
case Instruction::GetElementPtr: {
|
case Instruction::GetElementPtr: {
|
||||||
@ -3699,6 +3715,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
|||||||
int VecCost =
|
int VecCost =
|
||||||
TTI->getArithmeticInstrCost(Instruction::Add, VecTy, CostKind,
|
TTI->getArithmeticInstrCost(Instruction::Add, VecTy, CostKind,
|
||||||
Op1VK, Op2VK);
|
Op1VK, Op2VK);
|
||||||
|
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecCost, ScalarCost));
|
||||||
return ReuseShuffleCost + VecCost - ScalarCost;
|
return ReuseShuffleCost + VecCost - ScalarCost;
|
||||||
}
|
}
|
||||||
case Instruction::Load: {
|
case Instruction::Load: {
|
||||||
@ -3726,6 +3743,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
|||||||
VecLdCost += TTI->getShuffleCost(
|
VecLdCost += TTI->getShuffleCost(
|
||||||
TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
|
TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
|
||||||
}
|
}
|
||||||
|
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecLdCost, ScalarLdCost));
|
||||||
return ReuseShuffleCost + VecLdCost - ScalarLdCost;
|
return ReuseShuffleCost + VecLdCost - ScalarLdCost;
|
||||||
}
|
}
|
||||||
case Instruction::Store: {
|
case Instruction::Store: {
|
||||||
@ -3747,6 +3765,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
|||||||
VecStCost += TTI->getShuffleCost(
|
VecStCost += TTI->getShuffleCost(
|
||||||
TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
|
TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
|
||||||
}
|
}
|
||||||
|
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecStCost, ScalarStCost));
|
||||||
return ReuseShuffleCost + VecStCost - ScalarStCost;
|
return ReuseShuffleCost + VecStCost - ScalarStCost;
|
||||||
}
|
}
|
||||||
case Instruction::Call: {
|
case Instruction::Call: {
|
||||||
@ -3811,6 +3830,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
|
|||||||
TTI::CastContextHint::None, CostKind);
|
TTI::CastContextHint::None, CostKind);
|
||||||
}
|
}
|
||||||
VecCost += TTI->getShuffleCost(TargetTransformInfo::SK_Select, VecTy, 0);
|
VecCost += TTI->getShuffleCost(TargetTransformInfo::SK_Select, VecTy, 0);
|
||||||
|
LLVM_DEBUG(dumpTreeCosts(E, ReuseShuffleCost, VecCost, ScalarCost));
|
||||||
return ReuseShuffleCost + VecCost - ScalarCost;
|
return ReuseShuffleCost + VecCost - ScalarCost;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -4034,10 +4054,11 @@ int BoUpSLP::getTreeCost() {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int C = getEntryCost(&TE);
|
int C = getEntryCost(&TE);
|
||||||
|
Cost += C;
|
||||||
LLVM_DEBUG(dbgs() << "SLP: Adding cost " << C
|
LLVM_DEBUG(dbgs() << "SLP: Adding cost " << C
|
||||||
<< " for bundle that starts with " << *TE.Scalars[0]
|
<< " for bundle that starts with " << *TE.Scalars[0]
|
||||||
<< ".\n");
|
<< ".\n"
|
||||||
Cost += C;
|
<< "SLP: Current total cost = " << Cost << "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallPtrSet<Value *, 16> ExtractCostCalculated;
|
SmallPtrSet<Value *, 16> ExtractCostCalculated;
|
||||||
@ -5941,9 +5962,9 @@ bool SLPVectorizerPass::vectorizeStoreChain(ArrayRef<Value *> Chain, BoUpSLP &R,
|
|||||||
|
|
||||||
int Cost = R.getTreeCost();
|
int Cost = R.getTreeCost();
|
||||||
|
|
||||||
LLVM_DEBUG(dbgs() << "SLP: Found cost=" << Cost << " for VF=" << VF << "\n");
|
LLVM_DEBUG(dbgs() << "SLP: Found cost = " << Cost << " for VF =" << VF << "\n");
|
||||||
if (Cost < -SLPCostThreshold) {
|
if (Cost < -SLPCostThreshold) {
|
||||||
LLVM_DEBUG(dbgs() << "SLP: Decided to vectorize cost=" << Cost << "\n");
|
LLVM_DEBUG(dbgs() << "SLP: Decided to vectorize cost = " << Cost << "\n");
|
||||||
|
|
||||||
using namespace ore;
|
using namespace ore;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user