Skip to content

Commit bbe64d0

Browse files
authored
JIT: postorder local assertion prop for fieldwise block op indirs (#118368)
After we form the block op field indirs, run postorder local assertion prop on them, so that they see the same amount of assertion prop as other indirs. Fixes (parts of) #115789.
1 parent f23d779 commit bbe64d0

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/coreclr/jit/morphblock.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,32 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
11641164
addrSpillStore->SetMorphed(m_comp);
11651165
}
11661166

1167+
auto postOrderAssertionProp = [=](GenTree* tree) {
1168+
if (m_comp->fgGlobalMorph && m_comp->optLocalAssertionProp && (m_comp->optAssertionCount > 0))
1169+
{
1170+
GenTree* optimizedTree = tree;
1171+
bool again = JitConfig.JitEnablePostorderLocalAssertionProp() > 0;
1172+
bool didOptimize = false;
1173+
1174+
while (again)
1175+
{
1176+
tree = optimizedTree;
1177+
optimizedTree = m_comp->optAssertionProp(m_comp->apLocalPostorder, tree, nullptr, nullptr);
1178+
again = (optimizedTree != nullptr);
1179+
didOptimize |= again;
1180+
}
1181+
1182+
assert(tree != nullptr);
1183+
1184+
if (didOptimize)
1185+
{
1186+
m_comp->gtUpdateNodeSideEffects(tree);
1187+
}
1188+
}
1189+
1190+
return tree;
1191+
};
1192+
11671193
auto grabAddr = [=, &result](unsigned offs) {
11681194
GenTree* addrClone = nullptr;
11691195
// Need address of the source.
@@ -1316,6 +1342,8 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
13161342
}
13171343
}
13181344
assert(srcFld != nullptr);
1345+
1346+
srcFld = postOrderAssertionProp(srcFld);
13191347
srcFld->SetMorphed(m_comp);
13201348

13211349
GenTree* dstFldStore;
@@ -1372,7 +1400,16 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
13721400
}
13731401
}
13741402
}
1375-
noway_assert(dstFldStore->TypeGet() == srcFld->TypeGet());
1403+
1404+
// Allow mismatched types only when srcFld is an integer constant
1405+
//
1406+
if (dstFldStore->TypeGet() != srcFld->TypeGet())
1407+
{
1408+
noway_assert(genActualType(dstFldStore->TypeGet()) == genActualType(srcFld->TypeGet()));
1409+
assert(srcFld->IsIntegralConst());
1410+
}
1411+
1412+
dstFldStore = postOrderAssertionProp(dstFldStore);
13761413
dstFldStore->SetMorphed(m_comp);
13771414

13781415
if (m_comp->optLocalAssertionProp)

0 commit comments

Comments
 (0)