Skip to content

Commit 9694901

Browse files
JIT: Don't reverse copied condition in fgOptimizeBranch (#115842)
1 parent 8ea2168 commit 9694901

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

src/coreclr/jit/fgopt.cpp

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,42 +2734,20 @@ bool Compiler::fgOptimizeBranch(BasicBlock* bJump)
27342734
newStmtList->SetPrevStmt(newLastStmt);
27352735
}
27362736

2737-
//
2738-
// Reverse the sense of the compare
2739-
//
2740-
gtReverseCond(condTree);
2741-
27422737
// We need to update the following flags of the bJump block if they were set in the bDest block
27432738
bJump->CopyFlags(bDest, BBF_COPY_PROPAGATE);
27442739

27452740
// Update bbRefs and bbPreds
27462741
//
2747-
// For now we set the likelihood of the new branch to match
2748-
// the likelihood of the old branch.
2749-
//
2750-
// This may or may not match the block weight adjustments we're
2751-
// making. All this becomes easier to reconcile once we rely on
2752-
// edge likelihoods more and have synthesis running.
2753-
//
2754-
// Until then we won't worry that edges and blocks are potentially
2755-
// out of sync.
2756-
//
2757-
FlowEdge* const destFalseEdge = bDest->GetFalseEdge();
2758-
FlowEdge* const destTrueEdge = bDest->GetTrueEdge();
2759-
2760-
// bJump now falls through into the next block.
2761-
// Note that we're deriving the false edge's likelihood from 'destTrueEdge',
2762-
// because the comparison in 'bJump' is flipped.
2763-
// Similarly, we will derive the true edge's likelihood from 'destFalseEdge'.
2764-
//
2765-
FlowEdge* const falseEdge = fgAddRefPred(trueTarget, bJump, destTrueEdge);
2742+
FlowEdge* const falseEdge = bDest->GetFalseEdge();
2743+
FlowEdge* const trueEdge = bDest->GetTrueEdge();
27662744

2767-
// bJump now jumps to bDest's normal jump target
2768-
//
27692745
fgRedirectTargetEdge(bJump, falseTarget);
2770-
bJump->GetTargetEdge()->setLikelihood(destFalseEdge->getLikelihood());
2746+
bJump->GetTargetEdge()->setLikelihood(falseEdge->getLikelihood());
2747+
2748+
FlowEdge* const newTrueEdge = fgAddRefPred(trueTarget, bJump, trueEdge);
27712749

2772-
bJump->SetCond(bJump->GetTargetEdge(), falseEdge);
2750+
bJump->SetCond(newTrueEdge, bJump->GetTargetEdge());
27732751

27742752
// Update profile data
27752753
//

0 commit comments

Comments
 (0)