This repository was 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
Updating the HWIntrinsic codegen to support marking LoadVector128 and LoadAlignedVector128 as contained. #16095
Merged
Merged
Changes from all 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 |
---|---|---|
|
@@ -215,6 +215,9 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) | |
|
||
if (op2->isContained() || op2->isUsedFromSpillTemp()) | ||
{ | ||
assert((Compiler::flagsOfHWIntrinsic(node->gtHWIntrinsicId) & HW_Flag_NoContainment) == 0); | ||
assert(compiler->m_pLowering->IsContainableHWIntrinsicOp(node, op2) || op2->IsRegOptional()); | ||
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. Thanks! |
||
|
||
TempDsc* tmpDsc = nullptr; | ||
unsigned varNum = BAD_VAR_NUM; | ||
unsigned offset = (unsigned)-1; | ||
|
@@ -229,6 +232,11 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) | |
|
||
compiler->tmpRlsTemp(tmpDsc); | ||
} | ||
else if (op2->OperIsHWIntrinsic()) | ||
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. Similar code is needed in 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. Fixed. |
||
{ | ||
emit->emitIns_SIMD_R_R_AR(ins, simdSize, targetReg, op1Reg, op2->gtGetOp1()->gtRegNum); | ||
return; | ||
} | ||
else if (op2->isIndir()) | ||
{ | ||
GenTreeIndir* memIndir = op2->AsIndir(); | ||
|
@@ -242,7 +250,6 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) | |
offset = 0; | ||
|
||
// Ensure that all the GenTreeIndir values are set to their defaults. | ||
assert(memBase->gtRegNum == REG_NA); | ||
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 found to be incorrect in the larger |
||
assert(!memIndir->HasIndex()); | ||
assert(memIndir->Scale() == 1); | ||
assert(memIndir->Offset() == 0); | ||
|
@@ -310,6 +317,7 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins) | |
regNumber targetReg = node->gtRegNum; | ||
GenTree* op1 = node->gtGetOp1(); | ||
GenTree* op2 = node->gtGetOp2(); | ||
emitAttr simdSize = (emitAttr)(node->gtSIMDSize); | ||
int ival = Compiler::ivalOfHWIntrinsic(node->gtHWIntrinsicId); | ||
emitter* emit = getEmitter(); | ||
|
||
|
@@ -323,6 +331,9 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins) | |
|
||
if (op2->isContained() || op2->isUsedFromSpillTemp()) | ||
{ | ||
assert((Compiler::flagsOfHWIntrinsic(node->gtHWIntrinsicId) & HW_Flag_NoContainment) == 0); | ||
assert(compiler->m_pLowering->IsContainableHWIntrinsicOp(node, op2) || op2->IsRegOptional()); | ||
|
||
TempDsc* tmpDsc = nullptr; | ||
unsigned varNum = BAD_VAR_NUM; | ||
unsigned offset = (unsigned)-1; | ||
|
@@ -337,6 +348,11 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins) | |
|
||
compiler->tmpRlsTemp(tmpDsc); | ||
} | ||
else if (op2->OperIsHWIntrinsic()) | ||
{ | ||
emit->emitIns_SIMD_R_R_AR_I(ins, simdSize, targetReg, op1Reg, op2->gtGetOp1()->gtRegNum, ival); | ||
return; | ||
} | ||
else if (op2->isIndir()) | ||
{ | ||
GenTreeIndir* memIndir = op2->AsIndir(); | ||
|
@@ -350,7 +366,6 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins) | |
offset = 0; | ||
|
||
// Ensure that all the GenTreeIndir values are set to their defaults. | ||
assert(memBase->gtRegNum == REG_NA); | ||
assert(!memIndir->HasIndex()); | ||
assert(memIndir->Scale() == 1); | ||
assert(memIndir->Offset() == 0); | ||
|
@@ -360,14 +375,14 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins) | |
|
||
case GT_CLS_VAR_ADDR: | ||
{ | ||
emit->emitIns_SIMD_R_R_C_I(ins, emitTypeSize(targetType), targetReg, op1Reg, | ||
memBase->gtClsVar.gtClsVarHnd, 0, ival); | ||
emit->emitIns_SIMD_R_R_C_I(ins, simdSize, targetReg, op1Reg, memBase->gtClsVar.gtClsVarHnd, 0, | ||
ival); | ||
return; | ||
} | ||
|
||
default: | ||
{ | ||
emit->emitIns_SIMD_R_R_A_I(ins, emitTypeSize(targetType), targetReg, op1Reg, memIndir, ival); | ||
emit->emitIns_SIMD_R_R_A_I(ins, simdSize, targetReg, op1Reg, memIndir, ival); | ||
return; | ||
} | ||
} | ||
|
@@ -405,11 +420,11 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins) | |
assert((varNum != BAD_VAR_NUM) || (tmpDsc != nullptr)); | ||
assert(offset != (unsigned)-1); | ||
|
||
emit->emitIns_SIMD_R_R_S_I(ins, emitTypeSize(targetType), targetReg, op1Reg, varNum, offset, ival); | ||
emit->emitIns_SIMD_R_R_S_I(ins, simdSize, targetReg, op1Reg, varNum, offset, ival); | ||
} | ||
else | ||
{ | ||
emit->emitIns_SIMD_R_R_R_I(ins, emitTypeSize(targetType), targetReg, op1Reg, op2->gtRegNum, ival); | ||
emit->emitIns_SIMD_R_R_R_I(ins, simdSize, targetReg, op1Reg, op2->gtRegNum, ival); | ||
} | ||
} | ||
|
||
|
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.
It seems like this would be a good place to assert that
HW_Flag_NoContainment
is not set, or thatIsContainableHWIntrinsicOp(tree, tree->gtGetOp1())
but perhaps that's overkill.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 think asserting is a good idea. I'll update.
This is also pending #16114 and #16115. The former to fixup the various flags and the latter to make it easier to add some tests with this change (we currently don't have any tests that use
Load
,LoadScalar
, orLoadAligned
in a way that they could be contained).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.
Fixed.
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.
Hmm, actually, I can't easily check
IsContainableHWIntrinsicOp
.It is a member of
Lowering
and depends onIsContainableMemoryOp
, which itself depends onm_lsra
.I would need to make
m_pLowering
visible fromcompiler
somewhere to use that check.The other check,
flagsOfHWIntrinsic
, currently requires friend access to the compiler, but I don't see any reason why those can't be public.@CarolEidt, what would you recommend here?
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 can't recall why
IsContainableMemoryOp
has its actual implementation onLinearScan
when all the containment analysis is done inLowering
(even before we moved theTreeNodeInfoInit
to LSRA). In any case, it seems like something we might want to check during code generation, so we may want to expose it in some way. That said, I don't feel that it's critical.On the other hand, the
flagsOfHwIntrinsic
I think should definitely be public so that they are accessible from codegen.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.
Looks to be one use in LSRA, for
SIMDIntrinsicGetItem
: https://github.com/dotnet/coreclr/blob/master/src/jit/lsraxarch.cpp#L3026Exposing a
getLowering()
method in the compiler is easy enough, but it also requires us to#include "lower.h"
somewhere wherecodegen
can pick it up (probably just incodegen.h
). I've commented out this particular assert with a TODO and will finish looking tomorrow if I get the chance.It is already available to codgen, I just forgot to put the assert in an
#ifdef _TARGET_XARCH_
since its incodegenlinear
. 😄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.
Both asserts I tried to add here would have been invalid.
tree
is the node which was contained, we would want to be doing the assert on the node which containstree
.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.
Moved the asserts to
hwintrinsiccodegenxarch.cpp
.