@@ -2068,30 +2068,32 @@ class ShuffleVectorInst : public Instruction {
2068
2068
// / Return true if this shuffle mask chooses elements from exactly one source
2069
2069
// / vector.
2070
2070
// / Example: <7,5,undef,7>
2071
- // / This assumes that vector operands are the same length as the mask.
2072
- static bool isSingleSourceMask (ArrayRef<int > Mask);
2073
- static bool isSingleSourceMask (const Constant *Mask) {
2071
+ // / This assumes that vector operands (of length \p NumSrcElts) are the same
2072
+ // / length as the mask.
2073
+ static bool isSingleSourceMask (ArrayRef<int > Mask, int NumSrcElts);
2074
+ static bool isSingleSourceMask (const Constant *Mask, int NumSrcElts) {
2074
2075
assert (Mask->getType ()->isVectorTy () && " Shuffle needs vector constant." );
2075
2076
SmallVector<int , 16 > MaskAsInts;
2076
2077
getShuffleMask (Mask, MaskAsInts);
2077
- return isSingleSourceMask (MaskAsInts);
2078
+ return isSingleSourceMask (MaskAsInts, NumSrcElts );
2078
2079
}
2079
2080
2080
2081
// / Return true if this shuffle chooses elements from exactly one source
2081
2082
// / vector without changing the length of that vector.
2082
2083
// / Example: shufflevector <4 x n> A, <4 x n> B, <3,0,undef,3>
2083
2084
// / TODO: Optionally allow length-changing shuffles.
2084
2085
bool isSingleSource () const {
2085
- return !changesLength () && isSingleSourceMask (ShuffleMask);
2086
+ return !changesLength () &&
2087
+ isSingleSourceMask (ShuffleMask, ShuffleMask.size ());
2086
2088
}
2087
2089
2088
2090
// / Return true if this shuffle mask chooses elements from exactly one source
2089
2091
// / vector without lane crossings. A shuffle using this mask is not
2090
2092
// / necessarily a no-op because it may change the number of elements from its
2091
2093
// / input vectors or it may provide demanded bits knowledge via undef lanes.
2092
2094
// / Example: <undef,undef,2,3>
2093
- static bool isIdentityMask (ArrayRef<int > Mask);
2094
- static bool isIdentityMask (const Constant *Mask) {
2095
+ static bool isIdentityMask (ArrayRef<int > Mask, int NumSrcElts );
2096
+ static bool isIdentityMask (const Constant *Mask, int NumSrcElts ) {
2095
2097
assert (Mask->getType ()->isVectorTy () && " Shuffle needs vector constant." );
2096
2098
2097
2099
// Not possible to express a shuffle mask for a scalable vector for this
@@ -2101,7 +2103,7 @@ class ShuffleVectorInst : public Instruction {
2101
2103
2102
2104
SmallVector<int , 16 > MaskAsInts;
2103
2105
getShuffleMask (Mask, MaskAsInts);
2104
- return isIdentityMask (MaskAsInts);
2106
+ return isIdentityMask (MaskAsInts, NumSrcElts );
2105
2107
}
2106
2108
2107
2109
// / Return true if this shuffle chooses elements from exactly one source
@@ -2114,7 +2116,7 @@ class ShuffleVectorInst : public Instruction {
2114
2116
if (isa<ScalableVectorType>(getType ()))
2115
2117
return false ;
2116
2118
2117
- return !changesLength () && isIdentityMask (ShuffleMask);
2119
+ return !changesLength () && isIdentityMask (ShuffleMask, ShuffleMask. size () );
2118
2120
}
2119
2121
2120
2122
// / Return true if this shuffle lengthens exactly one source vector with
@@ -2138,12 +2140,12 @@ class ShuffleVectorInst : public Instruction {
2138
2140
// / In that case, the shuffle is better classified as an identity shuffle.
2139
2141
// / This assumes that vector operands are the same length as the mask
2140
2142
// / (a length-changing shuffle can never be equivalent to a vector select).
2141
- static bool isSelectMask (ArrayRef<int > Mask);
2142
- static bool isSelectMask (const Constant *Mask) {
2143
+ static bool isSelectMask (ArrayRef<int > Mask, int NumSrcElts );
2144
+ static bool isSelectMask (const Constant *Mask, int NumSrcElts ) {
2143
2145
assert (Mask->getType ()->isVectorTy () && " Shuffle needs vector constant." );
2144
2146
SmallVector<int , 16 > MaskAsInts;
2145
2147
getShuffleMask (Mask, MaskAsInts);
2146
- return isSelectMask (MaskAsInts);
2148
+ return isSelectMask (MaskAsInts, NumSrcElts );
2147
2149
}
2148
2150
2149
2151
// / Return true if this shuffle chooses elements from its source vectors
@@ -2155,39 +2157,41 @@ class ShuffleVectorInst : public Instruction {
2155
2157
// / In that case, the shuffle is better classified as an identity shuffle.
2156
2158
// / TODO: Optionally allow length-changing shuffles.
2157
2159
bool isSelect () const {
2158
- return !changesLength () && isSelectMask (ShuffleMask);
2160
+ return !changesLength () && isSelectMask (ShuffleMask, ShuffleMask. size () );
2159
2161
}
2160
2162
2161
2163
// / Return true if this shuffle mask swaps the order of elements from exactly
2162
2164
// / one source vector.
2163
2165
// / Example: <7,6,undef,4>
2164
- // / This assumes that vector operands are the same length as the mask.
2165
- static bool isReverseMask (ArrayRef<int > Mask);
2166
- static bool isReverseMask (const Constant *Mask) {
2166
+ // / This assumes that vector operands (of length \p NumSrcElts) are the same
2167
+ // / length as the mask.
2168
+ static bool isReverseMask (ArrayRef<int > Mask, int NumSrcElts);
2169
+ static bool isReverseMask (const Constant *Mask, int NumSrcElts) {
2167
2170
assert (Mask->getType ()->isVectorTy () && " Shuffle needs vector constant." );
2168
2171
SmallVector<int , 16 > MaskAsInts;
2169
2172
getShuffleMask (Mask, MaskAsInts);
2170
- return isReverseMask (MaskAsInts);
2173
+ return isReverseMask (MaskAsInts, NumSrcElts );
2171
2174
}
2172
2175
2173
2176
// / Return true if this shuffle swaps the order of elements from exactly
2174
2177
// / one source vector.
2175
2178
// / Example: shufflevector <4 x n> A, <4 x n> B, <3,undef,1,undef>
2176
2179
// / TODO: Optionally allow length-changing shuffles.
2177
2180
bool isReverse () const {
2178
- return !changesLength () && isReverseMask (ShuffleMask);
2181
+ return !changesLength () && isReverseMask (ShuffleMask, ShuffleMask. size () );
2179
2182
}
2180
2183
2181
2184
// / Return true if this shuffle mask chooses all elements with the same value
2182
2185
// / as the first element of exactly one source vector.
2183
2186
// / Example: <4,undef,undef,4>
2184
- // / This assumes that vector operands are the same length as the mask.
2185
- static bool isZeroEltSplatMask (ArrayRef<int > Mask);
2186
- static bool isZeroEltSplatMask (const Constant *Mask) {
2187
+ // / This assumes that vector operands (of length \p NumSrcElts) are the same
2188
+ // / length as the mask.
2189
+ static bool isZeroEltSplatMask (ArrayRef<int > Mask, int NumSrcElts);
2190
+ static bool isZeroEltSplatMask (const Constant *Mask, int NumSrcElts) {
2187
2191
assert (Mask->getType ()->isVectorTy () && " Shuffle needs vector constant." );
2188
2192
SmallVector<int , 16 > MaskAsInts;
2189
2193
getShuffleMask (Mask, MaskAsInts);
2190
- return isZeroEltSplatMask (MaskAsInts);
2194
+ return isZeroEltSplatMask (MaskAsInts, NumSrcElts );
2191
2195
}
2192
2196
2193
2197
// / Return true if all elements of this shuffle are the same value as the
@@ -2197,7 +2201,8 @@ class ShuffleVectorInst : public Instruction {
2197
2201
// / TODO: Optionally allow length-changing shuffles.
2198
2202
// / TODO: Optionally allow splats from other elements.
2199
2203
bool isZeroEltSplat () const {
2200
- return !changesLength () && isZeroEltSplatMask (ShuffleMask);
2204
+ return !changesLength () &&
2205
+ isZeroEltSplatMask (ShuffleMask, ShuffleMask.size ());
2201
2206
}
2202
2207
2203
2208
// / Return true if this shuffle mask is a transpose mask.
@@ -2232,12 +2237,12 @@ class ShuffleVectorInst : public Instruction {
2232
2237
// / ; Transposed matrix
2233
2238
// / t0 = < a, e, c, g > = shufflevector m0, m1 < 0, 4, 2, 6 >
2234
2239
// / t1 = < b, f, d, h > = shufflevector m0, m1 < 1, 5, 3, 7 >
2235
- static bool isTransposeMask (ArrayRef<int > Mask);
2236
- static bool isTransposeMask (const Constant *Mask) {
2240
+ static bool isTransposeMask (ArrayRef<int > Mask, int NumSrcElts );
2241
+ static bool isTransposeMask (const Constant *Mask, int NumSrcElts ) {
2237
2242
assert (Mask->getType ()->isVectorTy () && " Shuffle needs vector constant." );
2238
2243
SmallVector<int , 16 > MaskAsInts;
2239
2244
getShuffleMask (Mask, MaskAsInts);
2240
- return isTransposeMask (MaskAsInts);
2245
+ return isTransposeMask (MaskAsInts, NumSrcElts );
2241
2246
}
2242
2247
2243
2248
// / Return true if this shuffle transposes the elements of its inputs without
@@ -2246,27 +2251,30 @@ class ShuffleVectorInst : public Instruction {
2246
2251
// / exact specification.
2247
2252
// / Example: shufflevector <4 x n> A, <4 x n> B, <0,4,2,6>
2248
2253
bool isTranspose () const {
2249
- return !changesLength () && isTransposeMask (ShuffleMask);
2254
+ return !changesLength () && isTransposeMask (ShuffleMask, ShuffleMask. size () );
2250
2255
}
2251
2256
2252
2257
// / Return true if this shuffle mask is a splice mask, concatenating the two
2253
2258
// / inputs together and then extracts an original width vector starting from
2254
2259
// / the splice index.
2255
2260
// / Example: shufflevector <4 x n> A, <4 x n> B, <1,2,3,4>
2256
- static bool isSpliceMask (ArrayRef<int > Mask, int &Index);
2257
- static bool isSpliceMask (const Constant *Mask, int &Index) {
2261
+ // / This assumes that vector operands (of length \p NumSrcElts) are the same
2262
+ // / length as the mask.
2263
+ static bool isSpliceMask (ArrayRef<int > Mask, int NumSrcElts, int &Index);
2264
+ static bool isSpliceMask (const Constant *Mask, int NumSrcElts, int &Index) {
2258
2265
assert (Mask->getType ()->isVectorTy () && " Shuffle needs vector constant." );
2259
2266
SmallVector<int , 16 > MaskAsInts;
2260
2267
getShuffleMask (Mask, MaskAsInts);
2261
- return isSpliceMask (MaskAsInts, Index);
2268
+ return isSpliceMask (MaskAsInts, NumSrcElts, Index);
2262
2269
}
2263
2270
2264
2271
// / Return true if this shuffle splices two inputs without changing the length
2265
2272
// / of the vectors. This operation concatenates the two inputs together and
2266
2273
// / then extracts an original width vector starting from the splice index.
2267
2274
// / Example: shufflevector <4 x n> A, <4 x n> B, <1,2,3,4>
2268
2275
bool isSplice (int &Index) const {
2269
- return !changesLength () && isSpliceMask (ShuffleMask, Index);
2276
+ return !changesLength () &&
2277
+ isSpliceMask (ShuffleMask, ShuffleMask.size (), Index);
2270
2278
}
2271
2279
2272
2280
// / Return true if this shuffle mask is an extract subvector mask.
0 commit comments