mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-10 18:11:04 +09:00
JIT: Remove hasLikelihood checks; make FlowEdge::m_likelihoodSet debug-only (#99925)
Part of #93020. Now that edge likelihoods are expected to be set throughout all phases, when transferring the likelihood of an existing edge to a new edge, we should assume the former edge's likelihood should already be set. By removing all non-debug conditional logic that uses hasLikelihood, we can make m_likelihoodSet available only in Debug builds again.
This commit is contained in:
parent
682d1c7dad
commit
21bfbd5763
6 changed files with 31 additions and 30 deletions
|
@ -80,6 +80,7 @@ void FlowEdge::setLikelihood(weight_t likelihood)
|
|||
assert(likelihood >= 0.0);
|
||||
assert(likelihood <= 1.0);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (m_likelihoodSet)
|
||||
{
|
||||
JITDUMP("setting likelihood of " FMT_BB " -> " FMT_BB " from " FMT_WT " to " FMT_WT "\n", m_sourceBlock->bbNum,
|
||||
|
@ -92,7 +93,9 @@ void FlowEdge::setLikelihood(weight_t likelihood)
|
|||
}
|
||||
|
||||
m_likelihoodSet = true;
|
||||
m_likelihood = likelihood;
|
||||
#endif // DEBUG
|
||||
|
||||
m_likelihood = likelihood;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
|
|
@ -594,7 +594,7 @@ private:
|
|||
unsigned m_dupCount;
|
||||
|
||||
// True if likelihood has been set
|
||||
bool m_likelihoodSet;
|
||||
INDEBUG(bool m_likelihoodSet);
|
||||
|
||||
public:
|
||||
FlowEdge(BasicBlock* sourceBlock, BasicBlock* destBlock, FlowEdge* rest)
|
||||
|
@ -605,7 +605,9 @@ public:
|
|||
, m_edgeWeightMax(0)
|
||||
, m_likelihood(0)
|
||||
, m_dupCount(0)
|
||||
#ifdef DEBUG
|
||||
, m_likelihoodSet(false)
|
||||
#endif // DEBUG
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -668,6 +670,7 @@ public:
|
|||
|
||||
weight_t getLikelihood() const
|
||||
{
|
||||
assert(m_likelihoodSet);
|
||||
return m_likelihood;
|
||||
}
|
||||
|
||||
|
@ -676,14 +679,16 @@ public:
|
|||
|
||||
void clearLikelihood()
|
||||
{
|
||||
m_likelihood = 0.0;
|
||||
m_likelihoodSet = false;
|
||||
m_likelihood = 0.0;
|
||||
INDEBUG(m_likelihoodSet = false);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool hasLikelihood() const
|
||||
{
|
||||
return m_likelihoodSet;
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
weight_t getLikelyWeight() const;
|
||||
|
||||
|
|
|
@ -730,10 +730,7 @@ void Compiler::fgReplaceJumpTarget(BasicBlock* block, BasicBlock* oldTarget, Bas
|
|||
assert(newEdge->getSourceBlock() == block);
|
||||
assert(newEdge->getDestinationBlock() == newTarget);
|
||||
|
||||
if (newEdge->hasLikelihood() && oldEdge->hasLikelihood())
|
||||
{
|
||||
newEdge->addLikelihood(oldEdge->getLikelihood());
|
||||
}
|
||||
newEdge->addLikelihood(oldEdge->getLikelihood());
|
||||
}
|
||||
|
||||
assert(changed);
|
||||
|
|
|
@ -185,9 +185,9 @@ FlowEdge* Compiler::fgAddRefPred(BasicBlock* block, BasicBlock* blockPred, FlowE
|
|||
{
|
||||
block->bbLastPred = flow;
|
||||
}
|
||||
else if ((oldEdge != nullptr) && oldEdge->hasLikelihood())
|
||||
else if (oldEdge != nullptr)
|
||||
{
|
||||
// Copy likelihood from old edge, if any.
|
||||
// Copy likelihood from old edge.
|
||||
//
|
||||
flow->setLikelihood(oldEdge->getLikelihood());
|
||||
}
|
||||
|
|
|
@ -1837,23 +1837,21 @@ bool Compiler::fgOptimizeSwitchBranches(BasicBlock* block)
|
|||
// Update edge likelihoods
|
||||
// Note old edge may still be "in use" so we decrease its likelihood.
|
||||
//
|
||||
if (oldEdge->hasLikelihood())
|
||||
|
||||
// We want to move this much likelihood from old->new
|
||||
//
|
||||
const weight_t likelihoodFraction = oldEdge->getLikelihood() / (oldEdge->getDupCount() + 1);
|
||||
|
||||
if (newEdge->getDupCount() == 1)
|
||||
{
|
||||
// We want to move this much likelihood from old->new
|
||||
//
|
||||
const weight_t likelihoodFraction = oldEdge->getLikelihood() / (oldEdge->getDupCount() + 1);
|
||||
|
||||
if (newEdge->getDupCount() == 1)
|
||||
{
|
||||
newEdge->setLikelihood(likelihoodFraction);
|
||||
}
|
||||
else
|
||||
{
|
||||
newEdge->addLikelihood(likelihoodFraction);
|
||||
}
|
||||
|
||||
oldEdge->addLikelihood(-likelihoodFraction);
|
||||
newEdge->setLikelihood(likelihoodFraction);
|
||||
}
|
||||
else
|
||||
{
|
||||
newEdge->addLikelihood(likelihoodFraction);
|
||||
}
|
||||
|
||||
oldEdge->addLikelihood(-likelihoodFraction);
|
||||
|
||||
// we optimized a Switch label - goto REPEAT_SWITCH to follow this new jump
|
||||
modified = true;
|
||||
|
|
|
@ -603,8 +603,7 @@ private:
|
|||
assert(prevCheckBlock->KindIs(BBJ_ALWAYS));
|
||||
assert(prevCheckBlock->JumpsToNext());
|
||||
FlowEdge* const prevCheckThenEdge = prevCheckBlock->GetTargetEdge();
|
||||
assert(prevCheckThenEdge->hasLikelihood());
|
||||
weight_t checkLikelihood = max(0.0, 1.0 - prevCheckThenEdge->getLikelihood());
|
||||
weight_t checkLikelihood = max(0.0, 1.0 - prevCheckThenEdge->getLikelihood());
|
||||
|
||||
JITDUMP("Level %u Check block " FMT_BB " success likelihood " FMT_WT "\n", checkIdx, checkBlock->bbNum,
|
||||
checkLikelihood);
|
||||
|
@ -1086,9 +1085,8 @@ private:
|
|||
// just use that to figure out the "else" likelihood.
|
||||
//
|
||||
assert(checkBlock->KindIs(BBJ_ALWAYS));
|
||||
FlowEdge* const checkThenEdge = checkBlock->GetTargetEdge();
|
||||
assert(checkThenEdge->hasLikelihood());
|
||||
weight_t elseLikelihood = max(0.0, 1.0 - checkThenEdge->getLikelihood());
|
||||
FlowEdge* const checkThenEdge = checkBlock->GetTargetEdge();
|
||||
weight_t elseLikelihood = max(0.0, 1.0 - checkThenEdge->getLikelihood());
|
||||
|
||||
// CheckBlock flows into elseBlock unless we deal with the case
|
||||
// where we know the last check is always true (in case of "exact" GDV)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue