Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4635,10 +4635,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
//
DoPhase(this, PHASE_EMPTY_TRY_CATCH_FAULT_2, &Compiler::fgRemoveEmptyTryCatchOrTryFault);

// Invert loops
//
DoPhase(this, PHASE_INVERT_LOOPS, &Compiler::optInvertLoops);

// Run some flow graph optimizations (but don't reorder)
//
DoPhase(this, PHASE_OPTIMIZE_FLOW, &Compiler::optOptimizeFlow);
Expand All @@ -4657,6 +4653,10 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
//
DoPhase(this, PHASE_FIND_LOOPS, &Compiler::optFindLoopsPhase);

// Invert loops
//
DoPhase(this, PHASE_INVERT_LOOPS, &Compiler::optInvertLoops);

// Scale block weights and mark run rarely blocks.
//
DoPhase(this, PHASE_SET_BLOCK_WEIGHTS, &Compiler::optSetBlockWeights);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7095,7 +7095,7 @@ class Compiler

OptInvertCountTreeInfoType optInvertCountTreeInfo(GenTree* tree);

bool optInvertWhileLoop(BasicBlock* block);
bool optTryInvertWhileLoop(FlowGraphNaturalLoop* loop);
bool optIfConvert(BasicBlock* block);

private:
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4737,7 +4737,12 @@ void Compiler::fgDebugCheckLoops()
loop->VisitRegularExitBlocks([=](BasicBlock* exit) {
for (BasicBlock* pred : exit->PredBlocks())
{
assert(loop->ContainsBlock(pred));
if (!loop->ContainsBlock(pred))
{
JITDUMP("Loop " FMT_LP " exit " FMT_BB " has non-loop predecessor " FMT_BB "\n",
loop->GetIndex(), exit->bbNum, pred->bbNum);
assert(!"Loop exit has non-loop predecessor");
}
}
return BasicBlockVisit::Continue;
});
Expand Down
15 changes: 6 additions & 9 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2662,9 +2662,10 @@ bool Compiler::fgOptimizeBranch(BasicBlock* bJump)
}
#endif // DEBUG

// Computing the duplication cost may have triggered node reordering, so return true to indicate we modified IR
if (costIsTooHigh)
{
return false;
return true;
}

/* Looks good - duplicate the conditional block */
Expand All @@ -2678,12 +2679,7 @@ bool Compiler::fgOptimizeBranch(BasicBlock* bJump)
{
// Clone/substitute the expression.
Statement* stmt = gtCloneStmt(curStmt);

// cloneExpr doesn't handle everything.
if (stmt == nullptr)
{
return false;
}
assert(stmt != nullptr);

if (fgNodeThreading == NodeThreading::AllTrees)
{
Expand Down Expand Up @@ -2714,9 +2710,10 @@ bool Compiler::fgOptimizeBranch(BasicBlock* bJump)
condTree = condTree->gtGetOp1();

// This condTree has to be a RelOp comparison.
if (condTree->OperIsCompare() == false)
// If not, return true since we created new nodes.
if (!condTree->OperIsCompare())
{
return false;
return true;
}

// Join the two linked lists.
Expand Down
Loading
Loading