@@ -2734,42 +2734,20 @@ bool Compiler::fgOptimizeBranch(BasicBlock* bJump)
2734
2734
newStmtList->SetPrevStmt (newLastStmt);
2735
2735
}
2736
2736
2737
- //
2738
- // Reverse the sense of the compare
2739
- //
2740
- gtReverseCond (condTree);
2741
-
2742
2737
// We need to update the following flags of the bJump block if they were set in the bDest block
2743
2738
bJump->CopyFlags (bDest, BBF_COPY_PROPAGATE);
2744
2739
2745
2740
// Update bbRefs and bbPreds
2746
2741
//
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 ();
2766
2744
2767
- // bJump now jumps to bDest's normal jump target
2768
- //
2769
2745
fgRedirectTargetEdge (bJump, falseTarget);
2770
- bJump->GetTargetEdge ()->setLikelihood (destFalseEdge->getLikelihood ());
2746
+ bJump->GetTargetEdge ()->setLikelihood (falseEdge->getLikelihood ());
2747
+
2748
+ FlowEdge* const newTrueEdge = fgAddRefPred (trueTarget, bJump, trueEdge);
2771
2749
2772
- bJump->SetCond (bJump->GetTargetEdge (), falseEdge );
2750
+ bJump->SetCond (newTrueEdge, bJump->GetTargetEdge ());
2773
2751
2774
2752
// Update profile data
2775
2753
//
0 commit comments