llvm.org GIT mirror llvm / 1c40e18
getSplatIndex assumes that the first element of the mask contains the splat index which is not always true if the mask contains undefs. Modified it to return the first non undef value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96621 91177308-0d34-0410-b5e6-96231b3b80d8 Mon P Wang 10 years ago
2 changed file(s) with 18 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
17631763 bool isSplat() const { return isSplatMask(Mask, getValueType(0)); }
17641764 int getSplatIndex() const {
17651765 assert(isSplat() && "Cannot get splat index for non-splat!");
1766 return Mask[0];
1766 EVT VT = getValueType(0);
1767 for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
1768 if (Mask[i] != -1)
1769 return Mask[i];
1770 }
1771 return -1;
17671772 }
17681773 static bool isSplatMask(const int *Mask, EVT VT);
17691774
None ; RUN: llc < %s -march=x86 -mattr=sse41 -o %t
1 ; RUN: grep pshufb %t | count 1
2
0 ; RUN: llc < %s -march=x86-64 -mattr=sse41 | FileCheck %s
31
42 define <8 x i16> @shuf6(<8 x i16> %T0, <8 x i16> %T1) nounwind readnone {
3 ; CHECK: pshufb
4 ; CHECK-NOT: pshufb
5 ; CHECK: ret
56 entry:
6 %tmp9 = shufflevector <8 x i16> %T0, <8 x i16> %T1, <8 x i32> < i32 3, i32 2, i32 0, i32 2, i32 1, i32 5, i32 6 , i32 undef >
7 ret <8 x i16> %tmp9
7 %tmp9 = shufflevector <8 x i16> %T0, <8 x i16> %T1, <8 x i32> < i32 3, i32 2, i32 0, i32 2, i32 1, i32 5, i32 6 , i32 undef >
8 ret <8 x i16> %tmp9
89 }
10
11 define <8 x i16> @shuf7(<8 x i16> %t0) {
12 ; CHECK: pshufd
13 %tmp10 = shufflevector <8 x i16> %t0, <8 x i16> undef, <8 x i32> < i32 undef, i32 2, i32 2, i32 2, i32 2, i32 2, i32 undef, i32 undef >
14 ret <8 x i16> %tmp10
15 }