Lines Matching defs:Shuf
1185 static bool isShuffleEquivalentToSelect(ShuffleVectorInst &Shuf) {
1188 if (isa<ScalableVectorType>(Shuf.getOperand(0)->getType()))
1191 int MaskSize = Shuf.getShuffleMask().size();
1193 cast<FixedVectorType>(Shuf.getOperand(0)->getType())->getNumElements();
1202 int Elt = Shuf.getMaskValue(i);
1289 auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0));
1290 if (!Shuf || !Shuf->isZeroEltSplat())
1295 if (isa<ScalableVectorType>(Shuf->getType()))
1305 Value *Op0 = Shuf->getOperand(0);
1314 cast<FixedVectorType>(Shuf->getType())->getNumElements();
1317 NewMask[i] = i == IdxC ? 0 : Shuf->getMaskValue(i);
1326 auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0));
1327 if (!Shuf || !match(Shuf->getOperand(1), m_Poison()) ||
1328 !(Shuf->isIdentityWithExtract() || Shuf->isIdentityWithPadding()))
1333 if (isa<ScalableVectorType>(Shuf->getType()))
1344 Value *X = Shuf->getOperand(0);
1353 cast<FixedVectorType>(Shuf->getType())->getNumElements();
1355 ArrayRef<int> OldMask = Shuf->getShuffleMask();
1371 return new ShuffleVectorInst(X, Shuf->getOperand(1), NewMask);
1412 if (auto *Shuf = dyn_cast<ShuffleVectorInst>(InsElt.getOperand(0))) {
1417 if (!match(Shuf->getOperand(1), m_Constant(ShufConstVec)) ||
1427 if (!isShuffleEquivalentToSelect(*Shuf))
1438 ArrayRef<int> Mask = Shuf->getShuffleMask();
1459 return new ShuffleVectorInst(Shuf->getOperand(0),
1735 if (Instruction *Shuf = foldConstantInsEltIntoShuffle(IE))
1736 return Shuf;
2099 static Instruction *foldSelectShuffleOfSelectShuffle(ShuffleVectorInst &Shuf) {
2100 assert(Shuf.isSelect() && "Must have select-equivalent shuffle");
2102 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2104 Shuf.getShuffleMask(Mask);
2146 static Instruction *foldSelectShuffleWith1Binop(ShuffleVectorInst &Shuf,
2148 assert(Shuf.isSelect() && "Must have select-equivalent shuffle");
2152 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2167 Constant *IdC = ConstantExpr::getBinOpIdentity(BOpcode, Shuf.getType(), true);
2180 if (Shuf.getType()->getElementType()->isFloatingPointTy() &&
2188 ArrayRef<int> Mask = Shuf.getShuffleMask();
2215 static Instruction *canonicalizeInsertSplat(ShuffleVectorInst &Shuf,
2217 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2218 ArrayRef<int> Mask = Shuf.getShuffleMask();
2229 PoisonValue *PoisonVec = PoisonValue::get(Shuf.getType());
2237 cast<FixedVectorType>(Shuf.getType())->getNumElements();
2247 Instruction *InstCombinerImpl::foldSelectShuffle(ShuffleVectorInst &Shuf) {
2248 if (!Shuf.isSelect())
2253 unsigned NumElts = cast<FixedVectorType>(Shuf.getType())->getNumElements();
2254 if (!match(Shuf.getOperand(1), m_Undef()) &&
2255 Shuf.getMaskValue(0) >= (int)NumElts) {
2258 Shuf.commute();
2259 return &Shuf;
2262 if (Instruction *I = foldSelectShuffleOfSelectShuffle(Shuf))
2266 Shuf, getSimplifyQuery().getWithInstruction(&Shuf)))
2270 if (!match(Shuf.getOperand(0), m_BinOp(B0)) ||
2271 !match(Shuf.getOperand(1), m_BinOp(B1)))
2319 ArrayRef<int> Mask = Shuf.getShuffleMask();
2380 return replaceInstUsesWith(Shuf, NewBO);
2386 static Instruction *foldTruncShuffle(ShuffleVectorInst &Shuf,
2389 Type *DestType = Shuf.getType();
2391 if (!match(Shuf.getOperand(0), m_BitCast(m_Value(X))) ||
2392 !match(Shuf.getOperand(1), m_Poison()) || !DestType->isIntOrIntVectorTy())
2404 assert(Shuf.changesLength() && !Shuf.increasesLength() &&
2411 ArrayRef<int> Mask = Shuf.getShuffleMask();
2427 static Instruction *narrowVectorSelect(ShuffleVectorInst &Shuf,
2431 if (!match(Shuf.getOperand(1), m_Poison()) || !Shuf.isIdentityWithExtract())
2437 if (!match(Shuf.getOperand(0),
2444 cast<FixedVectorType>(Shuf.getType())->getNumElements();
2455 Value *NarrowX = Builder.CreateShuffleVector(X, Shuf.getShuffleMask());
2456 Value *NarrowY = Builder.CreateShuffleVector(Y, Shuf.getShuffleMask());
2461 static Instruction *foldShuffleOfUnaryOps(ShuffleVectorInst &Shuf,
2463 auto *S0 = dyn_cast<Instruction>(Shuf.getOperand(0));
2472 if (S0->hasOneUse() && match(Shuf.getOperand(1), m_Poison())) {
2473 Value *NewShuf = Builder.CreateShuffleVector(X, Shuf.getShuffleMask());
2477 Function *FAbs = Intrinsic::getDeclaration(Shuf.getModule(),
2478 Intrinsic::fabs, Shuf.getType());
2485 auto *S1 = dyn_cast<Instruction>(Shuf.getOperand(1));
2493 Value *NewShuf = Builder.CreateShuffleVector(X, Y, Shuf.getShuffleMask());
2498 Function *FAbs = Intrinsic::getDeclaration(Shuf.getModule(),
2499 Intrinsic::fabs, Shuf.getType());
2508 static Instruction *foldCastShuffle(ShuffleVectorInst &Shuf,
2511 auto *Cast0 = dyn_cast<CastInst>(Shuf.getOperand(0));
2512 auto *Cast1 = dyn_cast<CastInst>(Shuf.getOperand(1));
2530 VectorType *ShufTy = Shuf.getType();
2531 VectorType *ShufOpTy = cast<VectorType>(Shuf.getOperand(0)->getType());
2552 Value *NewShuf = Builder.CreateShuffleVector(X, Y, Shuf.getShuffleMask());
2557 static Instruction *foldIdentityExtractShuffle(ShuffleVectorInst &Shuf) {
2558 Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1);
2559 if (!Shuf.isIdentityWithExtract() || !match(Op1, m_Poison()))
2567 Shuf.getType()->getPrimitiveSizeInBits())
2568 return new BitCastInst(X, Shuf.getType());
2592 unsigned NumElts = cast<FixedVectorType>(Shuf.getType())->getNumElements();
2598 int ExtractMaskElt = Shuf.getMaskValue(i);
2607 static Instruction *foldShuffleWithInsert(ShuffleVectorInst &Shuf,
2609 Value *V0 = Shuf.getOperand(0), *V1 = Shuf.getOperand(1);
2611 Shuf.getShuffleMask(Mask);
2626 return IC.replaceOperand(Shuf, 0, X);
2634 return IC.replaceOperand(Shuf, 1, X);
2695 static Instruction *foldIdentityPaddedShuffles(ShuffleVectorInst &Shuf) {
2699 auto *Shuffle0 = dyn_cast<ShuffleVectorInst>(Shuf.getOperand(0));
2700 auto *Shuffle1 = dyn_cast<ShuffleVectorInst>(Shuf.getOperand(1));
2713 !isPowerOf2_32(cast<FixedVectorType>(Shuf.getType())->getNumElements()) ||
2731 ArrayRef<int> Mask = Shuf.getShuffleMask();