Skip to content

Commit 75362f6

Browse files
committed
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 dotnet#93246.
1 parent e13667a commit 75362f6

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/coreclr/jit/assertionprop.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,18 @@ void Compiler::optAssertionInit(bool isLocalProp)
559559
optCrossBlockLocalAssertionProp = false;
560560
}
561561

562+
#ifdef DEBUG
563+
// Disable per method via range
564+
//
565+
static ConfigMethodRange s_range;
566+
s_range.EnsureInit(JitConfig.JitEnableCrossBlockLocalAssertionPropRange());
567+
if (!s_range.Contains(info.compMethodHash()))
568+
{
569+
JITDUMP("Disabling cross-block assertion prop by config range\n");
570+
optCrossBlockLocalAssertionProp = false;
571+
}
572+
#endif
573+
562574
// Disable if too many locals
563575
//
564576
// The typical number of local assertions is roughly proportional

src/coreclr/jit/jitconfigvalues.h

+1
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ CONFIG_STRING(JitEnableEarlyLivenessRange, W("JitEnableEarlyLivenessRange"))
460460
CONFIG_STRING(JitOnlyOptimizeRange,
461461
W("JitOnlyOptimizeRange")) // If set, all methods that do _not_ match are forced into MinOpts
462462
CONFIG_STRING(JitEnablePhysicalPromotionRange, W("JitEnablePhysicalPromotionRange"))
463+
CONFIG_STRING(JitEnableCrossBlockLocalAssertionPropRange, W("JitEnableCrossBlockLocalAssertionPropRange"))
463464

464465
CONFIG_INTEGER(JitDoSsa, W("JitDoSsa"), 1) // Perform Static Single Assignment (SSA) numbering on the variables
465466
CONFIG_INTEGER(JitDoValueNumber, W("JitDoValueNumber"), 1) // Perform value numbering on method expressions

src/coreclr/jit/morph.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -12940,12 +12940,13 @@ void Compiler::fgAssertionGen(GenTree* tree)
1294012940
// apLocal will be stored on bbAssertionOutIfFalse and be used for false successors.
1294112941
// apLocalIfTrue will be stored on bbAssertionOutIfTrue and be used for true successors.
1294212942
//
12943-
const bool doCondUpdates = tree->OperIs(GT_JTRUE) && compCurBB->KindIs(BBJ_COND) && (compCurBB->NumSucc() == 2);
12943+
const bool makeCondAssertions =
12944+
tree->OperIs(GT_JTRUE) && compCurBB->KindIs(BBJ_COND) && (compCurBB->NumSucc() == 2);
1294412945

1294512946
// Intialize apLocalIfTrue if we might look for it later,
1294612947
// even if it ends up identical to apLocal.
1294712948
//
12948-
if (doCondUpdates)
12949+
if (makeCondAssertions)
1294912950
{
1295012951
apLocalIfTrue = BitVecOps::MakeCopy(apTraits, apLocal);
1295112952
}
@@ -12957,7 +12958,7 @@ void Compiler::fgAssertionGen(GenTree* tree)
1295712958

1295812959
AssertionInfo info = tree->GetAssertionInfo();
1295912960

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

13902-
if (pred->KindIs(BBJ_COND) && (pred->NumSucc() == 2))
13904+
if (useCondAssertions)
1390313905
{
1390413906
if (block == pred->GetJumpDest())
1390513907
{
@@ -13919,7 +13921,7 @@ void Compiler::fgMorphBlock(BasicBlock* block, unsigned highestReachablePostorde
1391913921
//
1392013922
if (!hasPredAssertions)
1392113923
{
13922-
if (block->NumSucc() == 1)
13924+
if (pred->NumSucc() == 1)
1392313925
{
1392413926
apLocal = assertionsOut;
1392513927
}

0 commit comments

Comments
 (0)