-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Optimize Vector128/256.Equals via TestZ #55875
Changes from 10 commits
4558287
c129424
16cc234
b846016
65fbda2
cd32850
661a31c
b892666
33e304a
6bc3a50
eff49e1
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 |
---|---|---|
|
@@ -14223,6 +14223,47 @@ GenTree* Compiler::fgMorphSmpOpOptional(GenTreeOp* tree) | |
} | ||
break; | ||
|
||
#if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) | ||
case GT_HWINTRINSIC: | ||
{ | ||
GenTreeHWIntrinsic* hw = tree->AsHWIntrinsic(); | ||
switch (hw->gtHWIntrinsicId) | ||
{ | ||
case NI_SSE_Xor: | ||
case NI_SSE2_Xor: | ||
case NI_AVX_Xor: | ||
case NI_AVX2_Xor: | ||
{ | ||
EgorBo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Transform XOR(X, 0) to X for vectors | ||
GenTree* op1 = hw->gtGetOp1(); | ||
GenTree* op2 = hw->gtGetOp2(); | ||
if (!gtIsActiveCSE_Candidate(tree)) | ||
{ | ||
if (op1->IsIntegralConstVector(0) && !gtIsActiveCSE_Candidate(op1)) | ||
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 that 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. Xor is not used in but it currently handles this (Xor for floats) just fine: static Vector128<float> Foo(Vector128<float> v) =>
Sse.Xor(v, Vector128.Create(0).AsSingle()); 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. for zero float it might be tricky as e.g. 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 would it be tricky? You can account for Speaking of |
||
{ | ||
DEBUG_DESTROY_NODE(tree); | ||
DEBUG_DESTROY_NODE(op1); | ||
INDEBUG(op2->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); | ||
return op2; | ||
} | ||
if (op2->IsIntegralConstVector(0) && !gtIsActiveCSE_Candidate(op2)) | ||
{ | ||
DEBUG_DESTROY_NODE(tree); | ||
DEBUG_DESTROY_NODE(op2); | ||
INDEBUG(op1->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); | ||
return op1; | ||
} | ||
} | ||
break; | ||
} | ||
|
||
default: | ||
break; | ||
} | ||
break; | ||
} | ||
#endif // defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH) | ||
|
||
default: | ||
break; | ||
} | ||
|
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.
Do we have an existing issue for this
TODO
?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.
That's why I want to merge it - to start experimenting with it 🙂 the issue is #40381
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.
Thanks. I just wanted to make sure we had some github issue corresponding to the TODO, so its not just a comment we'll forget about