Lines Matching defs:Shuf

1251 static bool isShuffleEquivalentToSelect(ShuffleVectorInst &Shuf) {
1254 if (isa<ScalableVectorType>(Shuf.getOperand(0)->getType()))
1257 int MaskSize = Shuf.getShuffleMask().size();
1259 cast<FixedVectorType>(Shuf.getOperand(0)->getType())->getNumElements();
1268 int Elt = Shuf.getMaskValue(i);
1355 auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0));
1356 if (!Shuf || !Shuf->isZeroEltSplat())
1361 if (isa<ScalableVectorType>(Shuf->getType()))
1371 Value *Op0 = Shuf->getOperand(0);
1380 cast<FixedVectorType>(Shuf->getType())->getNumElements();
1383 NewMask[i] = i == IdxC ? 0 : Shuf->getMaskValue(i);
1392 auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0));
1393 if (!Shuf || !match(Shuf->getOperand(1), m_Poison()) ||
1394 !(Shuf->isIdentityWithExtract() || Shuf->isIdentityWithPadding()))
1399 if (isa<ScalableVectorType>(Shuf->getType()))
1410 Value *X = Shuf->getOperand(0);
1419 cast<FixedVectorType>(Shuf->getType())->getNumElements();
1421 ArrayRef<int> OldMask = Shuf->getShuffleMask();
1437 return new ShuffleVectorInst(X, Shuf->getOperand(1), NewMask);
1478 if (auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0))) {
1483 if (!match(Shuf->getOperand(1), m_Constant(ShufConstVec)) ||
1493 if (!isShuffleEquivalentToSelect(*Shuf))
1504 ArrayRef<int> Mask = Shuf->getShuffleMask();
1525 return new ShuffleVectorInst(Shuf->getOperand(0),
1801 if (Instruction *Shuf = foldConstantInsEltIntoShuffle(IE))
1802 return Shuf;
2165 static Instruction *foldSelectShuffleOfSelectShuffle(ShuffleVectorInst &Shuf) {
2166 assert(Shuf.isSelect() && "Must have select-equivalent shuffle");
2168 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2170 Shuf.getShuffleMask(Mask);
2212 static Instruction *foldSelectShuffleWith1Binop(ShuffleVectorInst &Shuf,
2214 assert(Shuf.isSelect() && "Must have select-equivalent shuffle");
2218 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2233 Constant *IdC = ConstantExpr::getBinOpIdentity(BOpcode, Shuf.getType(), true);
2246 if (Shuf.getType()->getElementType()->isFloatingPointTy() &&
2254 ArrayRef<int> Mask = Shuf.getShuffleMask();
2281 static Instruction *canonicalizeInsertSplat(ShuffleVectorInst &Shuf,
2283 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2284 ArrayRef<int> Mask = Shuf.getShuffleMask();
2295 PoisonValue *PoisonVec = PoisonValue::get(Shuf.getType());
2303 cast<FixedVectorType>(Shuf.getType())->getNumElements();
2313 Instruction *InstCombinerImpl::foldSelectShuffle(ShuffleVectorInst &Shuf) {
2314 if (!Shuf.isSelect())
2319 unsigned NumElts = cast<FixedVectorType>(Shuf.getType())->getNumElements();
2320 if (!match(Shuf.getOperand(1), m_Undef()) &&
2321 Shuf.getMaskValue(0) >= (int)NumElts) {
2324 Shuf.commute();
2325 return &Shuf;
2328 if (Instruction *I = foldSelectShuffleOfSelectShuffle(Shuf))
2332 Shuf, getSimplifyQuery().getWithInstruction(&Shuf)))
2336 if (!match(Shuf.getOperand(0), m_BinOp(B0)) ||
2337 !match(Shuf.getOperand(1), m_BinOp(B1)))
2385 ArrayRef<int> Mask = Shuf.getShuffleMask();
2446 return replaceInstUsesWith(Shuf, NewBO);
2452 static Instruction *foldTruncShuffle(ShuffleVectorInst &Shuf,
2455 Type *DestType = Shuf.getType();
2457 if (!match(Shuf.getOperand(0), m_BitCast(m_Value(X))) ||
2458 !match(Shuf.getOperand(1), m_Poison()) || !DestType->isIntOrIntVectorTy())
2470 assert(Shuf.changesLength() && !Shuf.increasesLength() &&
2477 ArrayRef<int> Mask = Shuf.getShuffleMask();
2493 static Instruction *narrowVectorSelect(ShuffleVectorInst &Shuf,
2497 if (!match(Shuf.getOperand(1), m_Poison()) || !Shuf.isIdentityWithExtract())
2503 if (!match(Shuf.getOperand(0),
2510 cast<FixedVectorType>(Shuf.getType())->getNumElements();
2521 Value *NarrowX = Builder.CreateShuffleVector(X, Shuf.getShuffleMask());
2522 Value *NarrowY = Builder.CreateShuffleVector(Y, Shuf.getShuffleMask());
2527 static Instruction *foldShuffleOfUnaryOps(ShuffleVectorInst &Shuf,
2529 auto *S0 = dyn_cast<Instruction>(Shuf.getOperand(0));
2538 if (S0->hasOneUse() && match(Shuf.getOperand(1), m_Poison())) {
2539 Value *NewShuf = Builder.CreateShuffleVector(X, Shuf.getShuffleMask());
2544 Shuf.getModule(), Intrinsic::fabs, Shuf.getType());
2551 auto *S1 = dyn_cast<Instruction>(Shuf.getOperand(1));
2559 Value *NewShuf = Builder.CreateShuffleVector(X, Y, Shuf.getShuffleMask());
2565 Shuf.getModule(), Intrinsic::fabs, Shuf.getType());
2574 static Instruction *foldCastShuffle(ShuffleVectorInst &Shuf,
2577 auto *Cast0 = dyn_cast<CastInst>(Shuf.getOperand(0));
2578 auto *Cast1 = dyn_cast<CastInst>(Shuf.getOperand(1));
2596 VectorType *ShufTy = Shuf.getType();
2597 VectorType *ShufOpTy = cast<VectorType>(Shuf.getOperand(0)->getType());
2618 Value *NewShuf = Builder.CreateShuffleVector(X, Y, Shuf.getShuffleMask());
2623 static Instruction *foldIdentityExtractShuffle(ShuffleVectorInst &Shuf) {
2624 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2625 if (!Shuf.isIdentityWithExtract() || !match(Op1, m_Poison()))
2633 Shuf.getType()->getPrimitiveSizeInBits())
2634 return new BitCastInst(X, Shuf.getType());
2658 unsigned NumElts = cast<FixedVectorType>(Shuf.getType())->getNumElements();
2664 int ExtractMaskElt = Shuf.getMaskValue(i);
2673 static Instruction *foldShuffleWithInsert(ShuffleVectorInst &Shuf,
2675 Value *V0 = Shuf.getOperand(0), *V1 = Shuf.getOperand(1);
2677 Shuf.getShuffleMask(Mask);
2692 return IC.replaceOperand(Shuf, 0, X);
2700 return IC.replaceOperand(Shuf, 1, X);
2761 static Instruction *foldIdentityPaddedShuffles(ShuffleVectorInst &Shuf) {
2765 auto *Shuffle0 = dyn_cast<ShuffleVectorInst>(Shuf.getOperand(0));
2766 auto *Shuffle1 = dyn_cast<ShuffleVectorInst>(Shuf.getOperand(1));
2779 !isPowerOf2_32(cast<FixedVectorType>(Shuf.getType())->getNumElements()) ||
2797 ArrayRef<int> Mask = Shuf.getShuffleMask();