Lines Matching refs:Shuf
1143 static bool isShuffleEquivalentToSelect(ShuffleVectorInst &Shuf) { in isShuffleEquivalentToSelect() argument
1146 if (isa<ScalableVectorType>(Shuf.getOperand(0)->getType())) in isShuffleEquivalentToSelect()
1149 int MaskSize = Shuf.getShuffleMask().size(); in isShuffleEquivalentToSelect()
1151 cast<FixedVectorType>(Shuf.getOperand(0)->getType())->getNumElements(); in isShuffleEquivalentToSelect()
1160 int Elt = Shuf.getMaskValue(i); in isShuffleEquivalentToSelect()
1246 auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0)); in foldInsEltIntoSplat() local
1247 if (!Shuf || !Shuf->isZeroEltSplat()) in foldInsEltIntoSplat()
1252 if (isa<ScalableVectorType>(Shuf->getType())) in foldInsEltIntoSplat()
1262 Value *Op0 = Shuf->getOperand(0); in foldInsEltIntoSplat()
1271 cast<FixedVectorType>(Shuf->getType())->getNumElements(); in foldInsEltIntoSplat()
1274 NewMask[i] = i == IdxC ? 0 : Shuf->getMaskValue(i); in foldInsEltIntoSplat()
1283 auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0)); in foldInsEltIntoIdentityShuffle() local
1284 if (!Shuf || !match(Shuf->getOperand(1), m_Undef()) || in foldInsEltIntoIdentityShuffle()
1285 !(Shuf->isIdentityWithExtract() || Shuf->isIdentityWithPadding())) in foldInsEltIntoIdentityShuffle()
1290 if (isa<ScalableVectorType>(Shuf->getType())) in foldInsEltIntoIdentityShuffle()
1301 Value *X = Shuf->getOperand(0); in foldInsEltIntoIdentityShuffle()
1310 cast<FixedVectorType>(Shuf->getType())->getNumElements(); in foldInsEltIntoIdentityShuffle()
1312 ArrayRef<int> OldMask = Shuf->getShuffleMask(); in foldInsEltIntoIdentityShuffle()
1328 return new ShuffleVectorInst(X, Shuf->getOperand(1), NewMask); in foldInsEltIntoIdentityShuffle()
1369 if (auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0))) { in foldConstantInsEltIntoShuffle() local
1374 if (!match(Shuf->getOperand(1), m_Constant(ShufConstVec)) || in foldConstantInsEltIntoShuffle()
1384 if (!isShuffleEquivalentToSelect(*Shuf)) in foldConstantInsEltIntoShuffle()
1395 ArrayRef<int> Mask = Shuf->getShuffleMask(); in foldConstantInsEltIntoShuffle()
1416 return new ShuffleVectorInst(Shuf->getOperand(0), in foldConstantInsEltIntoShuffle()
1607 if (Instruction *Shuf = foldConstantInsEltIntoShuffle(IE)) in visitInsertElementInst() local
1608 return Shuf; in visitInsertElementInst()
1960 static Instruction *foldSelectShuffleWith1Binop(ShuffleVectorInst &Shuf) { in foldSelectShuffleWith1Binop() argument
1961 assert(Shuf.isSelect() && "Must have select-equivalent shuffle"); in foldSelectShuffleWith1Binop()
1965 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1); in foldSelectShuffleWith1Binop()
1980 Constant *IdC = ConstantExpr::getBinOpIdentity(BOpcode, Shuf.getType(), true); in foldSelectShuffleWith1Binop()
1988 ArrayRef<int> Mask = Shuf.getShuffleMask(); in foldSelectShuffleWith1Binop()
2016 static Instruction *canonicalizeInsertSplat(ShuffleVectorInst &Shuf, in canonicalizeInsertSplat() argument
2018 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1); in canonicalizeInsertSplat()
2019 ArrayRef<int> Mask = Shuf.getShuffleMask(); in canonicalizeInsertSplat()
2030 UndefValue *UndefVec = UndefValue::get(Shuf.getType()); in canonicalizeInsertSplat()
2039 cast<FixedVectorType>(Shuf.getType())->getNumElements(); in canonicalizeInsertSplat()
2049 Instruction *InstCombinerImpl::foldSelectShuffle(ShuffleVectorInst &Shuf) { in foldSelectShuffle() argument
2050 if (!Shuf.isSelect()) in foldSelectShuffle()
2055 unsigned NumElts = cast<FixedVectorType>(Shuf.getType())->getNumElements(); in foldSelectShuffle()
2056 if (!match(Shuf.getOperand(1), m_Undef()) && in foldSelectShuffle()
2057 Shuf.getMaskValue(0) >= (int)NumElts) { in foldSelectShuffle()
2060 Shuf.commute(); in foldSelectShuffle()
2061 return &Shuf; in foldSelectShuffle()
2064 if (Instruction *I = foldSelectShuffleWith1Binop(Shuf)) in foldSelectShuffle()
2068 if (!match(Shuf.getOperand(0), m_BinOp(B0)) || in foldSelectShuffle()
2069 !match(Shuf.getOperand(1), m_BinOp(B1))) in foldSelectShuffle()
2117 ArrayRef<int> Mask = Shuf.getShuffleMask(); in foldSelectShuffle()
2178 return replaceInstUsesWith(Shuf, NewBO); in foldSelectShuffle()
2184 static Instruction *foldTruncShuffle(ShuffleVectorInst &Shuf, in foldTruncShuffle() argument
2187 Type *DestType = Shuf.getType(); in foldTruncShuffle()
2189 if (!match(Shuf.getOperand(0), m_BitCast(m_Value(X))) || in foldTruncShuffle()
2190 !match(Shuf.getOperand(1), m_Undef()) || !DestType->isIntOrIntVectorTy()) in foldTruncShuffle()
2202 assert(Shuf.changesLength() && !Shuf.increasesLength() && in foldTruncShuffle()
2209 ArrayRef<int> Mask = Shuf.getShuffleMask(); in foldTruncShuffle()
2225 static Instruction *narrowVectorSelect(ShuffleVectorInst &Shuf, in narrowVectorSelect() argument
2229 if (!match(Shuf.getOperand(1), m_Undef()) || !Shuf.isIdentityWithExtract()) in narrowVectorSelect()
2235 if (!match(Shuf.getOperand(0), in narrowVectorSelect()
2242 cast<FixedVectorType>(Shuf.getType())->getNumElements(); in narrowVectorSelect()
2252 Value *NarrowX = Builder.CreateShuffleVector(X, Shuf.getShuffleMask()); in narrowVectorSelect()
2253 Value *NarrowY = Builder.CreateShuffleVector(Y, Shuf.getShuffleMask()); in narrowVectorSelect()
2258 static Instruction *foldFNegShuffle(ShuffleVectorInst &Shuf, in foldFNegShuffle() argument
2262 if (!match(Shuf.getOperand(0), m_CombineAnd(m_Instruction(FNeg0), in foldFNegShuffle()
2267 if (FNeg0->hasOneUse() && match(Shuf.getOperand(1), m_Undef())) { in foldFNegShuffle()
2268 Value *NewShuf = Builder.CreateShuffleVector(X, Shuf.getShuffleMask()); in foldFNegShuffle()
2274 if (!match(Shuf.getOperand(1), m_CombineAnd(m_Instruction(FNeg1), in foldFNegShuffle()
2280 Value *NewShuf = Builder.CreateShuffleVector(X, Y, Shuf.getShuffleMask()); in foldFNegShuffle()
2291 static Instruction *foldCastShuffle(ShuffleVectorInst &Shuf, in foldCastShuffle() argument
2294 auto *Cast0 = dyn_cast<CastInst>(Shuf.getOperand(0)); in foldCastShuffle()
2295 auto *Cast1 = dyn_cast<CastInst>(Shuf.getOperand(1)); in foldCastShuffle()
2313 VectorType *ShufTy = Shuf.getType(); in foldCastShuffle()
2314 VectorType *ShufOpTy = cast<VectorType>(Shuf.getOperand(0)->getType()); in foldCastShuffle()
2335 Value *NewShuf = Builder.CreateShuffleVector(X, Y, Shuf.getShuffleMask()); in foldCastShuffle()
2340 static Instruction *foldIdentityExtractShuffle(ShuffleVectorInst &Shuf) { in foldIdentityExtractShuffle() argument
2341 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1); in foldIdentityExtractShuffle()
2342 if (!Shuf.isIdentityWithExtract() || !match(Op1, m_Undef())) in foldIdentityExtractShuffle()
2350 Shuf.getType()->getPrimitiveSizeInBits()) in foldIdentityExtractShuffle()
2351 return new BitCastInst(X, Shuf.getType()); in foldIdentityExtractShuffle()
2375 unsigned NumElts = cast<FixedVectorType>(Shuf.getType())->getNumElements(); in foldIdentityExtractShuffle()
2381 int ExtractMaskElt = Shuf.getMaskValue(i); in foldIdentityExtractShuffle()
2390 static Instruction *foldShuffleWithInsert(ShuffleVectorInst &Shuf, in foldShuffleWithInsert() argument
2392 Value *V0 = Shuf.getOperand(0), *V1 = Shuf.getOperand(1); in foldShuffleWithInsert()
2394 Shuf.getShuffleMask(Mask); in foldShuffleWithInsert()
2409 return IC.replaceOperand(Shuf, 0, X); in foldShuffleWithInsert()
2417 return IC.replaceOperand(Shuf, 1, X); in foldShuffleWithInsert()
2478 static Instruction *foldIdentityPaddedShuffles(ShuffleVectorInst &Shuf) { in foldIdentityPaddedShuffles() argument
2482 auto *Shuffle0 = dyn_cast<ShuffleVectorInst>(Shuf.getOperand(0)); in foldIdentityPaddedShuffles()
2483 auto *Shuffle1 = dyn_cast<ShuffleVectorInst>(Shuf.getOperand(1)); in foldIdentityPaddedShuffles()
2496 !isPowerOf2_32(cast<FixedVectorType>(Shuf.getType())->getNumElements()) || in foldIdentityPaddedShuffles()
2514 ArrayRef<int> Mask = Shuf.getShuffleMask(); in foldIdentityPaddedShuffles()