Skip to content

[X86] IsElementEquivalent - pull out exact matching for same index/op. #143367

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

Merged
merged 2 commits into from
Jun 9, 2025
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
7 changes: 5 additions & 2 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9790,6 +9790,10 @@ static bool IsElementEquivalent(int MaskSize, SDValue Op, SDValue ExpectedOp,
(int)ExpectedVT.getVectorNumElements() != MaskSize)
return false;

// Exact match.
if (Idx == ExpectedIdx && Op == ExpectedOp)
return true;

switch (Op.getOpcode()) {
case ISD::BUILD_VECTOR:
// If the values are build vectors, we can look through them to find
Expand Down Expand Up @@ -9837,8 +9841,7 @@ static bool IsElementEquivalent(int MaskSize, SDValue Op, SDValue ExpectedOp,
SmallVector<int, 8> Mask;
DecodeVPERMMask(MaskSize, Op.getConstantOperandVal(1), Mask);
SDValue Src = Op.getOperand(0);
return (Mask[Idx] == Mask[ExpectedIdx]) ||
IsElementEquivalent(MaskSize, Src, Src, Mask[Idx],
return IsElementEquivalent(MaskSize, Src, Src, Mask[Idx],
Mask[ExpectedIdx]);
}
break;
Expand Down