Skip to content

Commit 8101ace

Browse files
authored
JIT: propagate some block assertions after expansion (#75321)
In #74384 I modified morph to generate assertions before a block op was morphed, but after the source and dest were morphed. This misses generating some assertions that arise once the expanded form is known. We now re-run assertion gen on the expanded tree, when we do an `OneAsgBlock` expansion. Other cases my also prove profitable. Closes #75229.
1 parent b622489 commit 8101ace

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

src/coreclr/jit/morphblock.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class MorphInitBlockHelper
1919
virtual void TrySpecialCases();
2020
virtual void MorphStructCases();
2121

22-
void PropagateAssertions();
22+
void PropagateBlockAssertions();
23+
void PropagateExpansionAssertions();
2324

2425
virtual const char* GetHelperName() const
2526
{
@@ -127,7 +128,7 @@ GenTree* MorphInitBlockHelper::Morph()
127128

128129
PrepareDst();
129130
PrepareSrc();
130-
PropagateAssertions();
131+
PropagateBlockAssertions();
131132
TrySpecialCases();
132133

133134
if (m_transformationDecision == BlockTransformation::Undefined)
@@ -150,6 +151,8 @@ GenTree* MorphInitBlockHelper::Morph()
150151
}
151152
}
152153

154+
PropagateExpansionAssertions();
155+
153156
assert(m_transformationDecision != BlockTransformation::Undefined);
154157
assert(m_result != nullptr);
155158

@@ -278,22 +281,40 @@ void MorphInitBlockHelper::PrepareDst()
278281
}
279282

280283
//------------------------------------------------------------------------
281-
// PropagateAssertions: propagate assertions based on the original tree
284+
// PropagateBlockAssertions: propagate assertions based on the original tree
282285
//
283286
// Notes:
284287
// Once the init or copy tree is morphed, assertion gen can no
285288
// longer recognize what it means.
286289
//
287290
// So we generate assertions based on the original tree.
288291
//
289-
void MorphInitBlockHelper::PropagateAssertions()
292+
void MorphInitBlockHelper::PropagateBlockAssertions()
290293
{
291294
if (m_comp->optLocalAssertionProp)
292295
{
293296
m_comp->optAssertionGen(m_asg);
294297
}
295298
}
296299

300+
//------------------------------------------------------------------------
301+
// PropagateExpansionAssertions: propagate assertions based on the
302+
// expanded tree
303+
//
304+
// Notes:
305+
// After the copy/init is expanded, we may see additional expansions
306+
// to generate.
307+
//
308+
void MorphInitBlockHelper::PropagateExpansionAssertions()
309+
{
310+
// Consider doing this for FieldByField as well
311+
//
312+
if (m_comp->optLocalAssertionProp && (m_transformationDecision == BlockTransformation::OneAsgBlock))
313+
{
314+
m_comp->optAssertionGen(m_asg);
315+
}
316+
}
317+
297318
//------------------------------------------------------------------------
298319
// PrepareSrc: Transform the asg src to an appropriate form and initialize member fields
299320
// with information about it.

0 commit comments

Comments
 (0)