Skip to content
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
verify exception set
  • Loading branch information
AndyAyersMS committed Nov 8, 2021
commit abc92ea96f89162bf1a70c3a6fa05174a3832751
29 changes: 23 additions & 6 deletions src/coreclr/jit/redundantbranchopts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,14 @@ bool Compiler::optRedundantRelop(BasicBlock* const block)
return false;
}

// If there's just one statement, bail.
//
if (stmt == block->firstStmt())
{
JITDUMP(" -- no, no prior stmt\n");
return false;
}

GenTree* const jumpTree = stmt->GetRootNode();

if (!jumpTree->OperIs(GT_JTRUE))
Expand Down Expand Up @@ -828,13 +836,9 @@ bool Compiler::optRedundantRelop(BasicBlock* const block)
return false;
}

// If there's just one statement, bail.
// Save off the jump tree's liberal exceptional VN.
//
if (stmt == block->firstStmt())
{
JITDUMP(" -- no, no prior stmt\n");
return false;
}
const ValueNum treeExcVN = vnStore->VNExceptionSet(tree->GetVN(VNK_Liberal));

JITDUMP("\noptRedundantRelop in " FMT_BB "; jump tree is\n", block->bbNum);
DISPTREE(jumpTree);
Expand Down Expand Up @@ -1002,6 +1006,19 @@ bool Compiler::optRedundantRelop(BasicBlock* const block)

JITDUMP(" -- prev tree has relop with %s liberal VN\n", ValueNumStore::VNRelationString(vnRelationMatch));

// If the jump tree VN has exceptions, verify that the RHS tree has a superset.
//
if (treeExcVN != vnStore->VNForEmptyExcSet())
{
const ValueNum prevTreeExcVN = vnStore->VNExceptionSet(prevTreeRHS->GetVN(VNK_Liberal));

if (!vnStore->VNExcIsSubset(prevTreeExcVN, treeExcVN))
{
JITDUMP(" -- prev tree does not anticipate all jump tree exceptions\n");
break;
}
}

// See if we can safely move a copy of prevTreeRHS later, to replace tree.
// We can, if none of its lcls are killed.
//
Expand Down