Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JIT: Late expansion for casts#97075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
EgorBo merged 17 commits intodotnet:mainfromEgorBo:late-cast-expansion
Jan 19, 2024
Merged
Changes from1 commit
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
de14015
Late expansion of casts
EgorBoJan 17, 2024
2c72dea
Fix build
EgorBoJan 17, 2024
a5345fa
Address feedback
EgorBoJan 17, 2024
efdeae6
Clean up
EgorBoJan 17, 2024
587c66e
Improve TP
EgorBoJan 17, 2024
a72014f
Handle MustNot case
EgorBoJan 17, 2024
b147e67
Final clean up
EgorBoJan 17, 2024
aee96f2
No, this is the final clean up
EgorBoJan 18, 2024
2e6795c
Clean up
EgorBoJan 18, 2024
a5f7079
Apply suggestions from code review
EgorBoJan 18, 2024
34523d2
Address feedback
EgorBoJan 18, 2024
91b47eb
Merge branch 'late-cast-expansion' of github.com:EgorBo/runtime-1 int…
EgorBoJan 18, 2024
c189b80
remove more code
EgorBoJan 18, 2024
6684563
clean up
EgorBoJan 19, 2024
6f42250
Merge branch 'main' of github.com:dotnet/runtime into late-cast-expan…
EgorBoJan 19, 2024
cdb7b47
Fix control flow
EgorBoJan 19, 2024
e1122c8
Clean up
EgorBoJan 19, 2024
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
PrevPrevious commit
NextNext commit
remove more code
  • Loading branch information
@EgorBo
EgorBo committedJan 18, 2024
commitc189b8004e49d35207de14bcbcb3c71b0957469e
21 changes: 7 additions & 14 deletionssrc/coreclr/jit/helperexpansion.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1790,20 +1790,19 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt,
// ...
//
// nullcheckBb (BBJ_COND): [weight: 1.0]
// tmp = obj;
// if (tmp == null)
// goto lastBlock;
//
// typeCheckBb (BBJ_COND): [weight: 0.5]
// if (tmp->pMT == likelyClass)
// if (obj->pMT == likelyClass)
// goto typeCheckSucceedBb;
//
// fallbackBb (BBJ_ALWAYS): [weight: <profile>]
// tmp = helper_call(cls,tmp);
// tmp = helper_call(cls,obj);
// goto lastBlock;
//
// typeCheckSucceedBb (BBJ_ALWAYS): [weight: <profile>]
//nop(or tmp = null)
//tmp = obj;(or tmp = null in case of 'MustNot')
//
// lastBlock (BBJ_any): [weight: 1.0]
// use(tmp);
Expand All@@ -1812,23 +1811,17 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt,
// Block 1: nullcheckBb
// TODO-InlineCast: assertionprop should leave us a mark that objArg is never null, so we can omit this check
// it's too late to rely on upstream phases to do this for us (unless we do optRepeat).
GenTree* objTmp = gtNewLclVarNode(tmpNum);
GenTree* nullcheckOp = gtNewOperNode(GT_EQ, TYP_INT, objTmp, gtNewNull());
GenTree* nullcheckOp = gtNewOperNode(GT_EQ, TYP_INT, gtCloneExpr(objArg), gtNewNull());
nullcheckOp->gtFlags |= GTF_RELOP_JMP_USED;
BasicBlock* nullcheckBb = fgNewBBFromTreeAfter(BBJ_COND, firstBb, gtNewOperNode(GT_JTRUE, TYP_VOID, nullcheckOp),
debugInfo, lastBb, true);

// Set tmp's value to obj by default (before the nullcheck)
Statement* storeObjStmt = fgNewStmtAtBeg(nullcheckBb, gtNewTempStore(tmpNum, gtCloneExpr(objArg)), debugInfo);
gtSetStmtInfo(storeObjStmt);
fgSetStmtSeq(storeObjStmt);

// if likelyCls == clsArg, we can just use clsArg that we've just spilled to a temp
// it's a sort of manual CSE.
GenTree* likelyClsNode = gtNewIconEmbClsHndNode(likelyCls);

// Block 2: typeCheckBb
GenTree* mtCheck = gtNewOperNode(GT_EQ, TYP_INT, gtNewMethodTableLookup(gtCloneExpr(objTmp)), likelyClsNode);
GenTree* mtCheck = gtNewOperNode(GT_EQ, TYP_INT, gtNewMethodTableLookup(gtCloneExpr(objArg)), likelyClsNode);
mtCheck->gtFlags |= GTF_RELOP_JMP_USED;
GenTree* jtrue = gtNewOperNode(GT_JTRUE, TYP_VOID, mtCheck);
BasicBlock* typeCheckBb = fgNewBBFromTreeAfter(BBJ_COND, nullcheckBb, jtrue, debugInfo, lastBb, true);
Expand All@@ -1847,8 +1840,8 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt,
}
else
{
//Otherwise, no-op (for simplicity, some downstream phase will collect this block)
typeCheckSucceedTree =gtNewNothingNode();
//Just return the original obj (assign to tmpNum)
typeCheckSucceedTree =gtNewTempStore(tmpNum, gtCloneExpr(objArg));
}
BasicBlock* typeCheckSucceedBb =
fgNewBBFromTreeAfter(BBJ_ALWAYS, fallbackBb, typeCheckSucceedTree, debugInfo, lastBb);
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp