Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
JIT: fix cross-block local assertion prop bug; add range enable
Fix condition under which we can share a pred's assertion out vector.
Add the ability to disable cross-block local assertion prop via range.

Contributes to #93246.
  • Loading branch information
AndyAyersMS committed Nov 16, 2023
commit 75362f62d7caf68dbe87e15dcd50f9a21df86eda
12 changes: 12 additions & 0 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,18 @@ void Compiler::optAssertionInit(bool isLocalProp)
optCrossBlockLocalAssertionProp = false;
}

#ifdef DEBUG
// Disable per method via range
//
static ConfigMethodRange s_range;
s_range.EnsureInit(JitConfig.JitEnableCrossBlockLocalAssertionPropRange());
if (!s_range.Contains(info.compMethodHash()))
{
JITDUMP("Disabling cross-block assertion prop by config range\n");
optCrossBlockLocalAssertionProp = false;
}
#endif

// Disable if too many locals
//
// The typical number of local assertions is roughly proportional
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ CONFIG_STRING(JitEnableEarlyLivenessRange, W("JitEnableEarlyLivenessRange"))
CONFIG_STRING(JitOnlyOptimizeRange,
W("JitOnlyOptimizeRange")) // If set, all methods that do _not_ match are forced into MinOpts
CONFIG_STRING(JitEnablePhysicalPromotionRange, W("JitEnablePhysicalPromotionRange"))
CONFIG_STRING(JitEnableCrossBlockLocalAssertionPropRange, W("JitEnableCrossBlockLocalAssertionPropRange"))

CONFIG_INTEGER(JitDoSsa, W("JitDoSsa"), 1) // Perform Static Single Assignment (SSA) numbering on the variables
CONFIG_INTEGER(JitDoValueNumber, W("JitDoValueNumber"), 1) // Perform value numbering on method expressions
Expand Down
14 changes: 8 additions & 6 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12940,12 +12940,13 @@ void Compiler::fgAssertionGen(GenTree* tree)
// apLocal will be stored on bbAssertionOutIfFalse and be used for false successors.
// apLocalIfTrue will be stored on bbAssertionOutIfTrue and be used for true successors.
//
const bool doCondUpdates = tree->OperIs(GT_JTRUE) && compCurBB->KindIs(BBJ_COND) && (compCurBB->NumSucc() == 2);
const bool makeCondAssertions =
tree->OperIs(GT_JTRUE) && compCurBB->KindIs(BBJ_COND) && (compCurBB->NumSucc() == 2);

// Intialize apLocalIfTrue if we might look for it later,
// even if it ends up identical to apLocal.
//
if (doCondUpdates)
if (makeCondAssertions)
{
apLocalIfTrue = BitVecOps::MakeCopy(apTraits, apLocal);
}
Expand All @@ -12957,7 +12958,7 @@ void Compiler::fgAssertionGen(GenTree* tree)

AssertionInfo info = tree->GetAssertionInfo();

if (doCondUpdates)
if (makeCondAssertions)
{
// Update apLocal and apIfTrue with suitable assertions
// from the JTRUE
Expand Down Expand Up @@ -13897,9 +13898,10 @@ void Compiler::fgMorphBlock(BasicBlock* block, unsigned highestReachablePostorde
// Yes, pred assertions are available.
// If the pred is (a non-degenerate) BBJ_COND, fetch the appropriate out set.
//
ASSERT_TP assertionsOut = pred->bbAssertionOut;
ASSERT_TP assertionsOut = pred->bbAssertionOut;
const bool useCondAssertions = pred->KindIs(BBJ_COND) && (pred->NumSucc() == 2);

if (pred->KindIs(BBJ_COND) && (pred->NumSucc() == 2))
if (useCondAssertions)
{
if (block == pred->GetJumpDest())
{
Expand All @@ -13919,7 +13921,7 @@ void Compiler::fgMorphBlock(BasicBlock* block, unsigned highestReachablePostorde
//
if (!hasPredAssertions)
{
if (block->NumSucc() == 1)
if (pred->NumSucc() == 1)
{
apLocal = assertionsOut;
}
Expand Down