Skip to content

Commit

Permalink
Small tweak for branch optimizer (#95740)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo authored Dec 20, 2023
1 parent 7e039e6 commit 74f19df
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9140,6 +9140,17 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
case GT_GE:
case GT_GT:

// Change "CNS relop op2" to "op2 relop* CNS"
if (!optValnumCSE_phase && op1->IsIntegralConst() && tree->OperIsCompare() && gtCanSwapOrder(op1, op2))
{
std::swap(tree->AsOp()->gtOp1, tree->AsOp()->gtOp2);
tree->gtOper = GenTree::SwapRelop(tree->OperGet());

oper = tree->OperGet();
op1 = tree->gtGetOp1();
op2 = tree->gtGetOp2();
}

if (!optValnumCSE_phase && (op1->OperIs(GT_CAST) || op2->OperIs(GT_CAST)))
{
tree = fgOptimizeRelationalComparisonWithCasts(tree->AsOp());
Expand Down

0 comments on commit 74f19df

Please sign in to comment.