Skip to content

Commit da55feb

Browse files
committed
Returns InstructionCost for getBranchMispredictPenalty().
1 parent 645ba1f commit da55feb

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,11 @@ class TargetTransformInfo {
419419
/// this factor, it is very likely to be predicted correctly.
420420
BranchProbability getPredictableBranchThreshold() const;
421421

422-
// Returns an integer indicating how aggressive the target wants for
423-
// eliminating unpredictable branches. A zero return value means extra
424-
// optimization applied to them should be minimal.
425-
unsigned getBranchMispredictPenalty() const;
422+
/// Returns estimated penalty of a branch misprediction in latency. Indicates
423+
/// how aggressive the target wants for eliminating unpredictable branches. A
424+
/// zero return value means extra optimization applied to them should be
425+
/// minimal.
426+
InstructionCost getBranchMispredictPenalty() const;
426427

427428
/// Return true if branch divergence exists.
428429
///
@@ -1837,7 +1838,7 @@ class TargetTransformInfo::Concept {
18371838
ArrayRef<const Value *> Operands,
18381839
TargetCostKind CostKind) = 0;
18391840
virtual BranchProbability getPredictableBranchThreshold() = 0;
1840-
virtual unsigned getBranchMispredictPenalty() = 0;
1841+
virtual InstructionCost getBranchMispredictPenalty() = 0;
18411842
virtual bool hasBranchDivergence(const Function *F = nullptr) = 0;
18421843
virtual bool isSourceOfDivergence(const Value *V) = 0;
18431844
virtual bool isAlwaysUniform(const Value *V) = 0;
@@ -2249,7 +2250,7 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
22492250
BranchProbability getPredictableBranchThreshold() override {
22502251
return Impl.getPredictableBranchThreshold();
22512252
}
2252-
unsigned getBranchMispredictPenalty() override {
2253+
InstructionCost getBranchMispredictPenalty() override {
22532254
return Impl.getBranchMispredictPenalty();
22542255
}
22552256
bool hasBranchDivergence(const Function *F = nullptr) override {

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class TargetTransformInfoImplBase {
9999
return BranchProbability(99, 100);
100100
}
101101

102-
unsigned getBranchMispredictPenalty() const { return 0; }
102+
InstructionCost getBranchMispredictPenalty() const { return 0; }
103103

104104
bool hasBranchDivergence(const Function *F = nullptr) const { return false; }
105105

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ BranchProbability TargetTransformInfo::getPredictableBranchThreshold() const {
279279
: TTIImpl->getPredictableBranchThreshold();
280280
}
281281

282-
unsigned TargetTransformInfo::getBranchMispredictPenalty() const {
282+
InstructionCost TargetTransformInfo::getBranchMispredictPenalty() const {
283283
return TTIImpl->getBranchMispredictPenalty();
284284
}
285285

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6757,7 +6757,7 @@ InstructionCost X86TTIImpl::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
67576757
return -1;
67586758
}
67596759

6760-
unsigned X86TTIImpl::getBranchMispredictPenalty() const {
6760+
InstructionCost X86TTIImpl::getBranchMispredictPenalty() const {
67616761
// TODO: Hook MispredictPenalty of SchedMachineModel into this.
67626762
return 14;
67636763
}

llvm/lib/Target/X86/X86TargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
294294
bool supportsEfficientVectorElementLoadStore() const;
295295
bool enableInterleavedAccessVectorization();
296296

297-
unsigned getBranchMispredictPenalty() const;
297+
InstructionCost getBranchMispredictPenalty() const;
298298

299299
private:
300300
bool supportsGather() const;

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,10 +3550,9 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
35503550
// that need to be moved to the dominating block.
35513551
SmallPtrSet<Instruction *, 4> AggressiveInsts;
35523552
InstructionCost Cost = 0;
3553-
unsigned Threshold = TwoEntryPHINodeFoldingThreshold;
3553+
InstructionCost Budget = TwoEntryPHINodeFoldingThreshold * TargetTransformInfo::TCC_Basic;
35543554
if (IsUnpredictable)
3555-
Threshold += TTI.getBranchMispredictPenalty();
3556-
InstructionCost Budget = Threshold * TargetTransformInfo::TCC_Basic;
3555+
Budget += TTI.getBranchMispredictPenalty();
35573556

35583557
bool Changed = false;
35593558
for (BasicBlock::iterator II = BB->begin(); isa<PHINode>(II);) {

0 commit comments

Comments
 (0)