diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-01-24 17:05:02 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-01-24 17:05:02 +0000 |
| commit | e5a0bcf7b838fe0a840a56fdab973af53ac8c11e (patch) | |
| tree | 116ba6c14bbaac39214bdf0a9051fe40625df699 /llvm/lib | |
| parent | 86bbf7ccee84962119c49ed1269f91d624614bff (diff) | |
| download | bcm5719-llvm-e5a0bcf7b838fe0a840a56fdab973af53ac8c11e.tar.gz bcm5719-llvm-e5a0bcf7b838fe0a840a56fdab973af53ac8c11e.zip | |
[x86] add low/high undef half shuffle mask helpers; NFC
This is the most common usage for isUndefInRange,
so make the code slightly less duplicated and more
readable.
llvm-svn: 352063
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 3bcd7ed40bf..5e7dad7c933 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -5068,8 +5068,8 @@ static bool isUndefOrZero(int Val) { return ((Val == SM_SentinelUndef) || (Val == SM_SentinelZero)); } -/// Return true if every element in Mask, beginning -/// from position Pos and ending in Pos+Size is the undef sentinel value. +/// Return true if every element in Mask, beginning from position Pos and ending +/// in Pos+Size is the undef sentinel value. static bool isUndefInRange(ArrayRef<int> Mask, unsigned Pos, unsigned Size) { for (unsigned i = Pos, e = Pos + Size; i != e; ++i) if (Mask[i] != SM_SentinelUndef) @@ -5077,6 +5077,18 @@ static bool isUndefInRange(ArrayRef<int> Mask, unsigned Pos, unsigned Size) { return true; } +/// Return true if the mask creates a vector whose lower half is undefined. +static bool isUndefLowerHalf(ArrayRef<int> Mask) { + unsigned NumElts = Mask.size(); + return isUndefInRange(Mask, 0, NumElts / 2); +} + +/// Return true if the mask creates a vector whose upper half is undefined. +static bool isUndefUpperHalf(ArrayRef<int> Mask) { + unsigned NumElts = Mask.size(); + return isUndefInRange(Mask, NumElts / 2, NumElts / 2); +} + /// Return true if Val falls within the specified range (L, H]. static bool isInRange(int Val, int Low, int Hi) { return (Val >= Low && Val < Hi); @@ -11045,7 +11057,7 @@ static bool matchVectorShuffleAsEXTRQ(MVT VT, SDValue &V1, SDValue &V2, assert(!Zeroable.isAllOnesValue() && "Fully zeroable shuffle mask"); // Upper half must be undefined. - if (!isUndefInRange(Mask, HalfSize, HalfSize)) + if (!isUndefUpperHalf(Mask)) return false; // Determine the extraction length from the part of the @@ -11100,7 +11112,7 @@ static bool matchVectorShuffleAsINSERTQ(MVT VT, SDValue &V1, SDValue &V2, assert(Size == (int)VT.getVectorNumElements() && "Unexpected mask size"); // Upper half must be undefined. - if (!isUndefInRange(Mask, HalfSize, HalfSize)) + if (!isUndefUpperHalf(Mask)) return false; for (int Idx = 0; Idx != HalfSize; ++Idx) { @@ -11271,8 +11283,7 @@ static SDValue lowerVectorShuffleAsSpecificZeroOrAnyExtend( DAG.getConstant(EltBits, DL, MVT::i8), DAG.getConstant(LoIdx, DL, MVT::i8))); - if (isUndefInRange(Mask, NumElements / 2, NumElements / 2) || - !SafeOffset(Offset + 1)) + if (isUndefUpperHalf(Mask) || !SafeOffset(Offset + 1)) return DAG.getBitcast(VT, Lo); int HiIdx = (Offset + 1) * EltBits; @@ -14352,8 +14363,8 @@ static SDValue lowerVectorShuffleWithUndefHalf(const SDLoc &DL, MVT VT, unsigned HalfNumElts = NumElts / 2; MVT HalfVT = MVT::getVectorVT(VT.getVectorElementType(), HalfNumElts); - bool UndefLower = isUndefInRange(Mask, 0, HalfNumElts); - bool UndefUpper = isUndefInRange(Mask, HalfNumElts, HalfNumElts); + bool UndefLower = isUndefLowerHalf(Mask); + bool UndefUpper = isUndefUpperHalf(Mask); if (!UndefLower && !UndefUpper) return SDValue(); |

