Skip to content
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

#78303 Add transformation ~v1 & v2 to VectorXxx.AndNot(v1, v2) #81993

Merged
merged 20 commits into from
Sep 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12121,6 +12121,63 @@ GenTree* Compiler::fgMorphMultiOp(GenTreeMultiOp* multiOp)
}
break;
}
case NI_SSE_And:
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
case NI_SSE2_And:
case NI_AVX_And:
case NI_AVX2_And:
{
// Transforms ~v1 & v2 to VectorXxx.AndNot(v1, v2)
GenTree* op1 = hw->Op(1);
GenTree* op2 = hw->Op(2);
if (!gtIsActiveCSE_Candidate(hw))
{
if (op1->OperIs(GT_HWINTRINSIC))
{
NamedIntrinsic ni = NI_Illegal;
GenTreeHWIntrinsic* inner_hw = op1->AsHWIntrinsic();
switch (inner_hw->GetHWIntrinsicId())
{
case NI_SSE_Xor:
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
ni = NI_SSE_AndNot;
break;
case NI_SSE2_Xor:
ni = NI_SSE2_AndNot;
break;
case NI_AVX_Xor:
ni = NI_AVX_AndNot;
break;
case NI_AVX2_Xor:
ni = NI_AVX2_AndNot;
break;
}

if (ni == NI_Illegal)
{
break;
}

var_types hw_type = hw->TypeGet();
CorInfoType hw_coretype = hw->GetSimdBaseJitType();
unsigned int hw_simdsize = hw->GetSimdSize();

GenTree* hw_lcv = op2->AsOp()->gtOp1;
GenTree* ihw_lcv = inner_hw->Op(1)->AsOp()->gtOp1;
GenTree* indOp1 = gtNewOperNode(GT_IND, hw_type, hw_lcv);
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
GenTree* indOp2 = gtNewOperNode(GT_IND, hw_type, ihw_lcv);
GenTreeHWIntrinsic* andnNode =
gtNewSimdHWIntrinsicNode(hw_type, indOp1, indOp2, ni, hw_coretype, hw_simdsize);

DEBUG_DESTROY_NODE(hw);
DEBUG_DESTROY_NODE(op1);
DEBUG_DESTROY_NODE(op2);

INDEBUG(andnNode->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED);

return andnNode;
}
}
break;
}
#endif

default:
Expand Down