Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
2dcd5e4
Expand runtime lookups in a late phase
EgorBo Feb 4, 2023
2c7a4a3
Clean up
EgorBo Feb 4, 2023
5754331
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Feb 5, 2023
dca8140
test
EgorBo Feb 6, 2023
e303869
test2
EgorBo Feb 6, 2023
aa760e5
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Feb 25, 2023
20e79dc
Test
EgorBo Feb 25, 2023
22f34a1
Enable JitDasmWithAlignmentBoundaries in Release
EgorBo Feb 25, 2023
c3681c1
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Feb 25, 2023
2110ec0
clean up
EgorBo Feb 25, 2023
54b224c
Revert "Enable JitDasmWithAlignmentBoundaries in Release"
EgorBo Feb 25, 2023
e4d4944
add hashtable
EgorBo Feb 25, 2023
3e272e0
test
EgorBo Feb 25, 2023
2671e14
Initial version (no dynamic expansion for now)
EgorBo Feb 25, 2023
64ae149
Clean up
EgorBo Feb 25, 2023
d991533
Clean up
EgorBo Feb 26, 2023
e20dd2d
Test
EgorBo Feb 26, 2023
8fc0374
Update BB flags properly
EgorBo Feb 26, 2023
269cb36
Add dynamic expansion path
EgorBo Feb 26, 2023
3c1cb1c
Add dynamic expansion
EgorBo Feb 26, 2023
47524ed
Add comments
EgorBo Feb 26, 2023
05ae42d
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Feb 28, 2023
ba8fdc2
test
EgorBo Feb 28, 2023
5d6cf4a
test #2
EgorBo Feb 28, 2023
ec00f5b
it should be <=
EgorBo Feb 28, 2023
ec893da
Update flowgraph.cpp
EgorBo Feb 28, 2023
f81882f
test 3
EgorBo Feb 28, 2023
d1d0bc8
test 4
EgorBo Mar 1, 2023
eea468a
test 4
EgorBo Mar 1, 2023
3d5d61a
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Mar 2, 2023
9af1079
Test 5
EgorBo Mar 2, 2023
ea3bf76
Clean up
EgorBo Mar 2, 2023
8a2a8ad
Found it!
EgorBo Mar 2, 2023
777def6
fix assert
EgorBo Mar 3, 2023
b18b12e
fix assert
EgorBo Mar 3, 2023
0f7fc3d
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Mar 3, 2023
5eee49b
move to separate file + fix some diff regressions
EgorBo Mar 3, 2023
2ff3799
Clean up, address some of the feedback
EgorBo Mar 3, 2023
11cac11
Address feedback [WIP]
EgorBo Mar 3, 2023
936c7d2
Implement gtSplitTree
jakobbotsch Mar 4, 2023
a982e68
Test
EgorBo Mar 4, 2023
aad1188
fix Release
EgorBo Mar 4, 2023
f3853a7
Fix assert
EgorBo Mar 4, 2023
f2d22fe
Initial clean up
EgorBo Mar 5, 2023
3e3b15f
Mark ArrayStack ctor explicit
jakobbotsch Mar 5, 2023
0f40259
Add docs to gtSplitTree
jakobbotsch Mar 5, 2023
2a29ac3
Fix up ASG(COMMA(...), ...) handling
jakobbotsch Mar 5, 2023
598ff71
Split out uses in execution order instead
jakobbotsch Mar 5, 2023
733fcd9
Remove dead local
jakobbotsch Mar 5, 2023
a62a135
Clean up
EgorBo Mar 5, 2023
730ed35
Avoid creating statements for non address-exposed locals
jakobbotsch Mar 5, 2023
9c6c89f
More cleanup (use callUse)
EgorBo Mar 5, 2023
f2c1508
use old path for tier0 (slightly better CQ/TP for tier0)
EgorBo Mar 5, 2023
c1cc980
Code clean up
EgorBo Mar 5, 2023
6f587df
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Mar 11, 2023
2834318
resolve conflicts
EgorBo Mar 11, 2023
79b5076
Update runtimelookup.cpp
EgorBo Mar 12, 2023
f0f14a7
Update src/coreclr/jit/runtimelookup.cpp
EgorBo Mar 12, 2023
6061fa7
Merge branch 'main' of github.com:dotnet/runtime into expand-runtime-…
EgorBo Mar 13, 2023
2a3d83b
Mitigate some tier0 regressions
EgorBo Mar 13, 2023
07cf9e7
clone fastpath for tier0
EgorBo Mar 13, 2023
3a3f4ca
Remove redundant impSpillSideEffects
EgorBo Mar 13, 2023
8af93a9
test
EgorBo Mar 14, 2023
afe2dd4
Fix regressions
EgorBo Mar 14, 2023
7909435
fix tp regressions
EgorBo Mar 14, 2023
258cbae
Apply suggestions from code review
EgorBo Mar 14, 2023
1afb6f8
Address feedback
EgorBo Mar 14, 2023
a116695
Add goto SCAN_BLOCK_AGAIN
EgorBo Mar 14, 2023
386446e
Update src/coreclr/jit/runtimelookup.cpp
EgorBo Mar 14, 2023
d2f3fec
Address feedback
EgorBo Mar 14, 2023
19034d9
update side effects for fallbackBb
EgorBo Mar 14, 2023
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
Next Next commit
Address feedback [WIP]
  • Loading branch information
EgorBo committed Mar 3, 2023
commit 11cac118ae1907440417fb76ba06c2489dc73636
2 changes: 2 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,8 @@ class Compiler
GenTreeFlags GenTreeFlags = GTF_SIDE_EFFECT,
bool ignoreRoot = false);

void gtSplitTree(BasicBlock* block, Statement* stmt, GenTree* splitPoint);

// Static fields of struct types (and sometimes the types that those are reduced to) are represented by having the
// static field contain an object pointer to the boxed struct. This simplifies the GC implementation...but
// complicates the JIT somewhat. This predicate returns "true" iff a node with type "fieldNodeType", representing
Expand Down
21 changes: 21 additions & 0 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,27 @@ inline void GenTree::BashToZeroConst(var_types type)
}
}

//------------------------------------------------------------------------
// BashToLclVar: Bash node to a LCL_VAR.
//
// Arguments:
// comp - compiler object
// lclNum - the local's number
//
// Return Value:
// The bashed node.
//
inline GenTreeLclVar* GenTree::BashToLclVar(Compiler* comp, unsigned lclNum)
{
LclVarDsc* varDsc = comp->lvaGetDesc(lclNum);

ChangeOper(GT_LCL_VAR);
ChangeType(varDsc->lvNormalizeOnLoad() ? varDsc->TypeGet() : genActualType(varDsc));
AsLclVar()->SetLclNum(lclNum);

return AsLclVar();
}

/*****************************************************************************
*
* Returns true if the node is of the "ovf" variety, for example, add.ovf.i1.
Expand Down
25 changes: 25 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16212,6 +16212,31 @@ bool Compiler::gtTreeHasSideEffects(GenTree* tree, GenTreeFlags flags /* = GTF_S
return true;
}

void Compiler::gtSplitTree(BasicBlock* block, Statement* stmt, GenTree* splitPoint)
{
class SideEffectSeparator final : public GenTreeVisitor<SideEffectSeparator>
{
public:
enum
{
DoPreOrder = true,
UseExecutionOrder = true
};

SideEffectSeparator(Compiler* compiler) : GenTreeVisitor(compiler)
{
// TODO:
}

fgWalkResult PreOrderVisit(GenTree** use, GenTree* user)
{
return Compiler::WALK_SKIP_SUBTREES;
}
};
SideEffectSeparator extractor(this);
extractor.WalkTree(stmt->GetRootNodePointer(), nullptr);
}

//------------------------------------------------------------------------
// gtExtractSideEffList: Extracts side effects from the given expression.
//
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1943,8 +1943,8 @@ struct GenTree

template <typename T>
void BashToConst(T value, var_types type = TYP_UNDEF);

void BashToZeroConst(var_types type);
GenTreeLclVar* BashToLclVar(Compiler* comp, unsigned lclNum);

#if NODEBASH_STATS
static void RecordOperBashing(genTreeOps operOld, genTreeOps operNew);
Expand Down
29 changes: 4 additions & 25 deletions src/coreclr/jit/lclmorph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>

case IndirTransform::BitCast:
indir->ChangeOper(GT_BITCAST);
lclNode = BashToLclVar(indir->gtGetOp1(), lclNum);
lclNode = indir->gtGetOp1()->BashToLclVar(m_compiler, lclNum);
break;

#ifdef FEATURE_HW_INTRINSICS
Expand All @@ -1166,7 +1166,7 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
{
GenTree* hwiNode = nullptr;
var_types elementType = indir->TypeGet();
lclNode = BashToLclVar(indir->gtGetOp1(), lclNum);
lclNode = indir->gtGetOp1()->BashToLclVar(m_compiler, lclNum);

if (elementType == TYP_FLOAT)
{
Expand Down Expand Up @@ -1195,7 +1195,7 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>

GenTree* hwiNode = nullptr;
var_types elementType = indir->TypeGet();
lclNode = BashToLclVar(indir, lclNum);
lclNode = indir->BashToLclVar(m_compiler, lclNum);
GenTree* simdLclNode = m_compiler->gtNewLclvNode(lclNum, varDsc->TypeGet());
GenTree* elementNode = user->gtGetOp2();

Expand Down Expand Up @@ -1252,7 +1252,7 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
assert(genTypeSize(varDsc) >= genTypeSize(indir));
assert(!isDef);

lclNode = BashToLclVar(indir->gtGetOp1(), lclNum);
lclNode = indir->gtGetOp1()->BashToLclVar(m_compiler, lclNum);
*val.Use() = m_compiler->gtNewCastNode(genActualType(indir), lclNode, false, indir->TypeGet());
break;

Expand Down Expand Up @@ -1670,27 +1670,6 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
return (user == nullptr) || (user->OperIs(GT_COMMA) && (user->AsOp()->gtGetOp1() == node));
}

//------------------------------------------------------------------------
// BashToLclVar: Bash node to a LCL_VAR.
//
// Arguments:
// node - the node to bash
// lclNum - the local's number
//
// Return Value:
// The bashed node.
//
GenTreeLclVar* BashToLclVar(GenTree* node, unsigned lclNum)
{
LclVarDsc* varDsc = m_compiler->lvaGetDesc(lclNum);

node->ChangeOper(GT_LCL_VAR);
node->ChangeType(varDsc->lvNormalizeOnLoad() ? varDsc->TypeGet() : genActualType(varDsc));
node->AsLclVar()->SetLclNum(lclNum);

return node->AsLclVar();
}

void SequenceLocal(GenTreeLclVarCommon* lcl)
{
if (m_sequencer != nullptr)
Expand Down
11 changes: 6 additions & 5 deletions src/coreclr/jit/runtimelookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,18 @@ PhaseStatus Compiler::fgExpandRuntimeLookups()
block->bbFlags |= originalFlags & (BBF_SPLIT_GAINED | BBF_IMPORTED | BBF_GC_SAFE_POINT |
BBF_LOOP_PREHEADER | BBF_RETLESS_CALL);

// We've just split a block (e.g. in the middle of it) into two blocks.
// We have to do the same for the current statement - move all side effects before the runtime
// lookup to prevBb
gtSplitTree(block, stmt, call);

// Define a local for the result
const unsigned rtLookupLclNum = lvaGrabTemp(true DEBUGARG("runtime lookup"));
lvaTable[rtLookupLclNum].lvType = TYP_I_IMPL;
GenTreeLclVar* rtLookupLcl = gtNewLclvNode(rtLookupLclNum, call->TypeGet());

// Save expression to a local and append as the last statement in prevBb
auto spillExpr = [&](GenTree* expr) -> GenTree* {
if (expr->OperIs(GT_LCL_VAR))
{
return gtClone(expr);
}
unsigned const tmpNum = lvaGrabTemp(false DEBUGARG("spilling expr"));
lvaTable[tmpNum].lvType = expr->TypeGet();
Statement* asgStmt = fgNewStmtAtEnd(prevBb, gtNewTempAssign(tmpNum, expr));
Expand Down Expand Up @@ -313,7 +314,7 @@ PhaseStatus Compiler::fgExpandRuntimeLookups()
}

// Replace call with rtLookupLclNum local
call->ReplaceWith(gtNewLclvNode(rtLookupLclNum, call->TypeGet()), this);
call->BashToLclVar(this, rtLookupLclNum);
gtUpdateTreeAncestorsSideEffects(call);
gtSetStmtInfo(stmt);
fgSetStmtSeq(stmt);
Expand Down