[llvm] r369211 - [X86] isTargetShuffleEquivalent - early out on illegal shuffle masks. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 09:37:59 PDT 2019
Author: rksimon
Date: Sun Aug 18 09:37:58 2019
New Revision: 369211
URL: http://llvm.org/viewvc/llvm-project?rev=369211&view=rev
Log:
[X86] isTargetShuffleEquivalent - early out on illegal shuffle masks. NFCI.
Simplifies shuffle mask comparisons by just bailing out if the shuffle mask has any out of range values - will make an upcoming patch much simpler.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=369211&r1=369210&r2=369211&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Aug 18 09:37:58 2019
@@ -10075,7 +10075,8 @@ static bool isShuffleEquivalent(SDValue
/// If an element in Mask matches SM_SentinelUndef (-1) then the corresponding
/// value in ExpectedMask is always accepted. Otherwise the indices must match.
///
-/// SM_SentinelZero is accepted as a valid negative index but must match in both.
+/// SM_SentinelZero is accepted as a valid negative index but must match in
+/// both.
static bool isTargetShuffleEquivalent(ArrayRef<int> Mask,
ArrayRef<int> ExpectedMask) {
int Size = Mask.size();
@@ -10084,14 +10085,15 @@ static bool isTargetShuffleEquivalent(Ar
assert(isUndefOrZeroOrInRange(ExpectedMask, 0, 2 * Size) &&
"Illegal target shuffle mask");
- for (int i = 0; i < Size; ++i)
- if (Mask[i] == SM_SentinelUndef)
- continue;
- else if (Mask[i] < 0 && Mask[i] != SM_SentinelZero)
- return false;
- else if (Mask[i] != ExpectedMask[i])
- return false;
+ // Check for out-of-range target shuffle mask indices.
+ if (!isUndefOrZeroOrInRange(Mask, 0, 2 * Size))
+ return false;
+ for (int i = 0; i < Size; ++i) {
+ if (Mask[i] == SM_SentinelUndef || Mask[i] == ExpectedMask[i])
+ continue;
+ return false;
+ }
return true;
}
More information about the llvm-commits
mailing list