This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Struct & SIMD improvements #22255
Merged
Merged
Struct & SIMD improvements #22255
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -618,21 +618,8 @@ inline void Compiler::impAppendStmt(GenTree* stmt, unsigned chkLevel) | |
// Since we don't know what it assigns to, we need to spill global refs. | ||
spillGlobEffects = true; | ||
} | ||
else if (!expr->OperIsBlkOp()) | ||
else if ((lhs->gtFlags & GTF_GLOB_REF) != 0) | ||
{ | ||
// If we are assigning to a global ref, we have to spill global refs on stack | ||
if ((lhs->gtFlags & GTF_GLOB_REF) != 0) | ||
{ | ||
spillGlobEffects = true; | ||
} | ||
} | ||
else if ((lhs->OperIsBlk() && !lhs->AsBlk()->HasGCPtr()) || | ||
((lhs->OperGet() == GT_LCL_VAR) && | ||
(lvaTable[lhs->AsLclVarCommon()->gtLclNum].lvStructGcCount == 0))) | ||
{ | ||
// TODO-1stClassStructs: Previously, spillGlobEffects was set to true for | ||
// GT_INITBLK and GT_COPYBLK, but this is overly conservative, and should be | ||
// revisited. (Note that it was NOT set to true for GT_COPYOBJ.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was where we were previously always spilling on a non-COPYOBJ block assignment. This was (clearly) overly conservative, but by eliminating this conservatism, I failed to add the struct case to the code in |
||
spillGlobEffects = true; | ||
} | ||
} | ||
|
@@ -1389,8 +1376,6 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, | |
} | ||
if (dest == nullptr) | ||
{ | ||
// TODO-1stClassStructs: We shouldn't really need a block node as the destination | ||
// if this is a known struct type. | ||
if (asgType == TYP_STRUCT) | ||
{ | ||
dest = gtNewObjNode(structHnd, destAddr); | ||
|
@@ -1401,10 +1386,6 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, | |
dest->gtFlags &= ~GTF_GLOB_REF; | ||
dest->gtFlags |= (destAddr->gtFlags & GTF_GLOB_REF); | ||
} | ||
else if (varTypeIsStruct(asgType)) | ||
{ | ||
dest = new (this, GT_BLK) GenTreeBlk(GT_BLK, asgType, destAddr, genTypeSize(asgType)); | ||
} | ||
else | ||
{ | ||
dest = gtNewOperNode(GT_IND, asgType, destAddr); | ||
|
@@ -14527,9 +14508,8 @@ void Compiler::impImportBlockCode(BasicBlock* block) | |
assert(!"Unexpected fieldAccessor"); | ||
} | ||
|
||
// Create the member assignment, unless we have a struct. | ||
// TODO-1stClassStructs: This could be limited to TYP_STRUCT, to avoid extra copies. | ||
bool deferStructAssign = varTypeIsStruct(lclTyp); | ||
// Create the member assignment, unless we have a TYP_STRUCT. | ||
bool deferStructAssign = (lclTyp == TYP_STRUCT); | ||
|
||
if (!deferStructAssign) | ||
{ | ||
|
@@ -16220,10 +16200,6 @@ GenTree* Compiler::impAssignSmallStructTypeToVar(GenTree* op, CORINFO_CLASS_HAND | |
unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Return value temp for small struct return.")); | ||
impAssignTempGen(tmpNum, op, hClass, (unsigned)CHECK_SPILL_ALL); | ||
GenTree* ret = gtNewLclvNode(tmpNum, lvaTable[tmpNum].lvType); | ||
|
||
// TODO-1stClassStructs: Handle constant propagation and CSE-ing of small struct returns. | ||
ret->gtFlags |= GTF_DONT_CSE; | ||
|
||
return ret; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is similar handle searching logic in
gtGetClassHandle
-- perhaps factor this out as a helper method?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're really quite different, and though some logic could be sharable, the ref context seems quite different from the value-type context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just get rid of this completly? It seems preferrable to keep
GT_OBJ
nodes around and extract the struct handle from those instead of attempting to recover handles fromGT_IND
this way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we'd like to get rid of this in the long term, but this code is to deal with cases where we have already made that transformation. I'm going to look into this a bit further, so that I better understand the cases that require this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, my comment was targeted at long term. Well, maybe not that long, just only after I'm done with #21705 that makes
GT_OBJ
node "small" and overall cheap.