-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix perf issues discovered in "For software performance, can you always trust inlining" blog #61408
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a433102
1673244
72fb64e
dddf349
4f4c709
80897b4
3368ff2
bd38782
8967fce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2620,29 +2620,58 @@ unsigned Compiler::gtSetMultiOpOrder(GenTreeMultiOp* multiOp) | |
| unsigned level = 0; | ||
| unsigned lvl2 = 0; | ||
|
|
||
| #if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) | ||
| if (multiOp->OperIs(GT_HWINTRINSIC) && (multiOp->GetOperandCount() == 1) && | ||
| multiOp->AsHWIntrinsic()->OperIsMemoryLoadOrStore()) | ||
| #if defined(FEATURE_HW_INTRINSICS) | ||
| if (multiOp->OperIs(GT_HWINTRINSIC)) | ||
| { | ||
| costEx = IND_COST_EX; | ||
| costSz = 2; | ||
| GenTreeHWIntrinsic* hwTree = multiOp->AsHWIntrinsic(); | ||
| #if defined(TARGET_XARCH) | ||
| if ((hwTree->GetOperandCount() == 1) && hwTree->OperIsMemoryLoadOrStore()) | ||
| { | ||
| costEx = IND_COST_EX; | ||
| costSz = 2; | ||
|
|
||
| GenTree* addr = multiOp->Op(1)->gtEffectiveVal(); | ||
| level = gtSetEvalOrder(addr); | ||
| GenTree* addr = hwTree->Op(1)->gtEffectiveVal(); | ||
| level = gtSetEvalOrder(addr); | ||
|
|
||
| // See if we can form a complex addressing mode. | ||
| if (addr->OperIs(GT_ADD) && gtMarkAddrMode(addr, &costEx, &costSz, multiOp->TypeGet())) | ||
| { | ||
| // Nothing to do, costs have been set. | ||
| // See if we can form a complex addressing mode. | ||
| if (addr->OperIs(GT_ADD) && gtMarkAddrMode(addr, &costEx, &costSz, hwTree->TypeGet())) | ||
| { | ||
| // Nothing to do, costs have been set. | ||
| } | ||
| else | ||
| { | ||
| costEx += addr->GetCostEx(); | ||
| costSz += addr->GetCostSz(); | ||
| } | ||
|
|
||
| hwTree->SetCosts(costEx, costSz); | ||
| return level; | ||
| } | ||
| else | ||
| #endif | ||
| switch (hwTree->GetHWIntrinsicId()) | ||
| { | ||
| costEx += addr->GetCostEx(); | ||
| costSz += addr->GetCostSz(); | ||
| #if defined(TARGET_XARCH) | ||
| case NI_Vector128_Create: | ||
| case NI_Vector256_Create: | ||
| #elif defined(TARGET_ARM64) | ||
| case NI_Vector64_Create: | ||
| case NI_Vector128_Create: | ||
| #endif | ||
| { | ||
| if ((hwTree->GetOperandCount() == 1) && hwTree->Op(1)->OperIsConst()) | ||
|
Member
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. Why are we only doing What about the cases where
Member
Author
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. @tannergooding yeah, they are assigned a higher cost automatically due to multiple arguments so the problem doesn't reproduce for them. but that's a good point, I guess Vector128.Create(1,2,3,4,5,6,7,8) currently gets a very high cost while in reality it should still be 3/2
Member
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. I think its fine to log an issue for and cover in a separate issue here. |
||
| { | ||
| // Vector.Create(cns) is cheap but not that cheap to be (1,1) | ||
| costEx = IND_COST_EX; | ||
| costSz = 2; | ||
| level = gtSetEvalOrder(hwTree->Op(1)); | ||
| hwTree->SetCosts(costEx, costSz); | ||
| return level; | ||
| } | ||
| break; | ||
| } | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| multiOp->SetCosts(costEx, costSz); | ||
| return level; | ||
| } | ||
| #endif // defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.