Skip to content
Merged
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3414,6 +3414,37 @@ GenTree* Lowering::LowerHWIntrinsicCndSel(GenTreeHWIntrinsic* node)
blendVariableId = NI_EVEX_BlendVariableMask;
op1 = maskNode;
}
else if (op2->IsVectorZero() || op3->IsVectorZero())
{
// If either of the value operands is const zero, we can optimize down to AND or AND_NOT.
GenTree* binOp = nullptr;

if (op3->IsVectorZero())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have nodes of type ConvertMaskToVector(Vector.Zero) for op2 or op3. I just opened #114272 to fix a case where I was not checking that for arm64.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a way we'd create that currently on xarch, but I plan on reviving #110342 and will keep that possibility in mind since we'll more eagerly choose intrinsics that produce a mask with that.

{
binOp = comp->gtNewSimdBinOpNode(GT_AND, simdType, op1, op2, simdBaseJitType, simdSize);
BlockRange().Remove(op3);
}
else
{
binOp = comp->gtNewSimdBinOpNode(GT_AND_NOT, simdType, op3, op1, simdBaseJitType, simdSize);
BlockRange().Remove(op2);
}

BlockRange().InsertAfter(node, binOp);

LIR::Use use;
if (BlockRange().TryGetUse(node, &use))
{
use.ReplaceWith(binOp);
}
else
{
binOp->SetUnusedValue();
}

BlockRange().Remove(node);
return LowerNode(binOp);
}
else if (simdSize == 32)
{
// For Vector256 (simdSize == 32), BlendVariable for floats/doubles
Expand Down
Loading