-
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
Morph Vector.Create(0)
to Vector.Zero
#63821
Conversation
This is very close to being ready; only 1 test regressed in perf on x64: - vxorps xmm0, xmm0, xmm0
+ vmovupd xmm0, xmmword ptr [reloc @RWD96]
vmovapd xmmword ptr [rbp-60H], xmm0
- vxorps xmm0, xmm0, xmm0
+ vmovupd xmm0, xmmword ptr [reloc @RWD96] Will investigate. Edit: This was fixed by reverting back the lowering change. Seems we need to have similar optimizations in morph and lowering. |
@dotnet/jit-contrib this is ready again. |
…reate-to-get_Zero
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.
LGTM. Just a nit and a question around whether a check is still good to keep.
@@ -7651,16 +7651,20 @@ inline bool GenTree::IsSIMDZero() const | |||
// | |||
inline bool GenTree::IsFloatPositiveZero() const | |||
{ | |||
return IsCnsFltOrDbl() && !IsCnsNonZeroFltOrDbl(); | |||
if (IsCnsFltOrDbl()) |
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 ...
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
why is !optValnumCSE_phase
check needed?
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 was added because I was deleting nodes; however, I'm not deleting the nodes anymore and instead using ResetHWIntrinsic
. I do feel safer having that guard there in-case more optimizations get added in fgOptimizeHWIntrinsic
.
Read more in the discussion: #63821 (comment)
@jakobbotsch , since you approved this PR: #65028 - and it depends on this one, I'm wondering if you approve of this one as well. |
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.
LGTM. Just a couple minor comments.
@@ -7651,16 +7651,20 @@ inline bool GenTree::IsSIMDZero() const | |||
// | |||
inline bool GenTree::IsFloatPositiveZero() const | |||
{ | |||
return IsCnsFltOrDbl() && !IsCnsNonZeroFltOrDbl(); | |||
if (IsCnsFltOrDbl()) |
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 ...
Sorry I didn't get to it yesterday @TIHan, but looks like Andy unblocked you. |
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.
LGTM as well.
No worries, thank you all for the reviews! |
…reate-to-get_Zero
Addresses #63490
Currently, this PR is dependent on #62933 due to using
IsFloatPositiveZero
.Description
This PR will normalize
Vector.Create(0)
calls to simply becomeVector.Zero
calls, for example:will turn into
This happens in the morph phase.
Acceptance Criteria
Vector.Create
callsSome ARM64 diffs
Some x64 diffs
(The diff isn't really a regression, a move got shuffled around, but wanted to mention it)