-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Morph Vector.Create(0)
to Vector.Zero
#63821
Changes from 67 commits
7aca5dc
2752913
526e6c8
d850426
0ee6450
cb5a82e
6ae9a94
5c1997f
b33c72c
fd19fdc
178ff52
c0a23c0
ad780ea
83c26ab
9f7e7da
1e67415
25b9d92
c0dc7e4
a718944
1f45fa2
cb872da
c0708d7
bf49d11
bc7a557
5939f36
6cd0ea8
2b30421
0828de6
fa43d19
911f929
b91be1e
760a08c
c1a90b4
32f86c1
b08f552
c89e47b
956e50a
2b526c9
d51a988
77c3d25
b1065e8
451f8e3
e231131
64ad95f
333fc67
bc02904
d8c39e3
a5e51d5
38d9e7e
fb6047c
bc1b9f4
d7904b6
dbe1990
5b7d991
5a7f674
377b794
1cf0b32
84f51cd
31cd50d
383f147
29fb977
51eae5a
7d06ebf
177cd53
32ac1fc
36c4001
759e8c0
4c0f768
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 |
---|---|---|
|
@@ -13433,6 +13433,89 @@ GenTree* Compiler::fgOptimizeRelationalComparisonWithConst(GenTreeOp* cmp) | |
return cmp; | ||
} | ||
|
||
#ifdef FEATURE_HW_INTRINSICS | ||
|
||
//------------------------------------------------------------------------ | ||
// fgOptimizeHWIntrinsic: optimize a HW intrinsic node | ||
// | ||
// Arguments: | ||
// node - HWIntrinsic node to examine | ||
// | ||
// Returns: | ||
// The original node if no optimization happened or if tree bashing occured. | ||
// An alternative tree if an optimization happened. | ||
// | ||
// Notes: | ||
// Checks for HWIntrinsic nodes: Vector64.Create/Vector128.Create/Vector256.Create, | ||
// and if the call is one of these, attempt to optimize. | ||
// This is post-order, meaning that it will not morph the children. | ||
// | ||
GenTree* Compiler::fgOptimizeHWIntrinsic(GenTreeHWIntrinsic* node) | ||
{ | ||
assert(!optValnumCSE_phase); | ||
|
||
if (opts.OptimizationDisabled()) | ||
{ | ||
return node; | ||
} | ||
|
||
switch (node->GetHWIntrinsicId()) | ||
{ | ||
case NI_Vector128_Create: | ||
#if defined(TARGET_XARCH) | ||
case NI_Vector256_Create: | ||
#elif defined(TARGET_ARM64) | ||
case NI_Vector64_Create: | ||
#endif | ||
{ | ||
bool hwAllArgsAreConstZero = true; | ||
for (GenTree* arg : node->Operands()) | ||
{ | ||
if (!arg->IsIntegralConst(0) && !arg->IsFloatPositiveZero()) | ||
{ | ||
hwAllArgsAreConstZero = false; | ||
break; | ||
} | ||
} | ||
|
||
if (hwAllArgsAreConstZero) | ||
{ | ||
switch (node->GetHWIntrinsicId()) | ||
{ | ||
case NI_Vector128_Create: | ||
{ | ||
node->ResetHWIntrinsicId(NI_Vector128_get_Zero); | ||
break; | ||
} | ||
#if defined(TARGET_XARCH) | ||
case NI_Vector256_Create: | ||
{ | ||
node->ResetHWIntrinsicId(NI_Vector256_get_Zero); | ||
break; | ||
} | ||
#elif defined(TARGET_ARM64) | ||
case NI_Vector64_Create: | ||
{ | ||
node->ResetHWIntrinsicId(NI_Vector64_get_Zero); | ||
break; | ||
} | ||
#endif | ||
default: | ||
unreached(); | ||
} | ||
} | ||
break; | ||
} | ||
|
||
default: | ||
break; | ||
} | ||
|
||
return node; | ||
} | ||
|
||
#endif | ||
|
||
//------------------------------------------------------------------------ | ||
// fgOptimizeCommutativeArithmetic: Optimizes commutative operations. | ||
// | ||
|
@@ -14349,6 +14432,13 @@ GenTree* Compiler::fgMorphMultiOp(GenTreeMultiOp* multiOp) | |
} | ||
#endif // defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) | ||
|
||
#ifdef FEATURE_HW_INTRINSICS | ||
if (multiOp->OperIsHWIntrinsic() && !optValnumCSE_phase) | ||
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 is 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. It was added because I was deleting nodes; however, I'm not deleting the nodes anymore and instead using Read more in the discussion: #63821 (comment) |
||
{ | ||
return fgOptimizeHWIntrinsic(multiOp->AsHWIntrinsic()); | ||
} | ||
#endif | ||
|
||
return multiOp; | ||
} | ||
#endif // defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS) | ||
|
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.
why is this change? Seems
IsCnsNonZeroFltOrDbl
already does 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.
It does, but we decided that
!IsCnsNonZeroFltOrDbl()
is a bit confusing; an explicit implementation seemed to be clearer.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.
Perhaps add a comment explaining why you're not using
!IsCns ...