Lines Matching refs:II

292 static Value *simplifyX86immShift(const IntrinsicInst &II,
297 switch (II.getIntrinsicID()) {
363 auto Arg1 = II.getArgOperand(1);
390 auto Vec = II.getArgOperand(0);
426 static Value *simplifyX86varShift(const IntrinsicInst &II,
431 switch (II.getIntrinsicID()) {
473 auto *CShift = dyn_cast<Constant>(II.getArgOperand(1));
477 auto Vec = II.getArgOperand(0);
478 auto VT = cast<VectorType>(II.getType());
550 static Value *simplifyX86pack(IntrinsicInst &II,
552 Value *Arg0 = II.getArgOperand(0);
553 Value *Arg1 = II.getArgOperand(1);
554 Type *ResTy = II.getType();
616 static Value *simplifyX86movmsk(const IntrinsicInst &II,
618 Value *Arg = II.getArgOperand(0);
619 Type *ResTy = II.getType();
646 static Value *simplifyX86addcarry(const IntrinsicInst &II,
648 Value *CarryIn = II.getArgOperand(0);
649 Value *Op1 = II.getArgOperand(1);
650 Value *Op2 = II.getArgOperand(2);
651 Type *RetTy = II.getType();
673 static Value *simplifyX86insertps(const IntrinsicInst &II,
675 auto *CInt = dyn_cast<ConstantInt>(II.getArgOperand(2));
679 VectorType *VecTy = cast<VectorType>(II.getType());
703 Value *V1 = II.getArgOperand(1);
708 if ((II.getArgOperand(0) == II.getArgOperand(1)) ||
727 return Builder.CreateShuffleVector(II.getArgOperand(0), V1, ShuffleMask);
732 static Value *simplifyX86extrq(IntrinsicInst &II, Value *Op0,
736 Type *IntTy64 = Type::getInt64Ty(II.getContext());
770 return UndefValue::get(II.getType());
779 Type *IntTy8 = Type::getInt8Ty(II.getContext());
780 Type *IntTy32 = Type::getInt32Ty(II.getContext());
796 return Builder.CreateBitCast(SV, II.getType());
809 if (II.getIntrinsicID() == Intrinsic::x86_sse4a_extrq) {
811 Module *M = II.getModule();
826 static Value *simplifyX86insertq(IntrinsicInst &II, Value *Op0, Value *Op1,
850 return UndefValue::get(II.getType());
859 Type *IntTy8 = Type::getInt8Ty(II.getContext());
860 Type *IntTy32 = Type::getInt32Ty(II.getContext());
877 return Builder.CreateBitCast(SV, II.getType());
898 Type *IntTy64 = Type::getInt64Ty(II.getContext());
906 if (II.getIntrinsicID() == Intrinsic::x86_sse4a_insertq) {
907 Type *IntTy8 = Type::getInt8Ty(II.getContext());
912 Module *M = II.getModule();
921 static Value *simplifyX86pshufb(const IntrinsicInst &II,
923 Constant *V = dyn_cast<Constant>(II.getArgOperand(1));
927 auto *VecTy = cast<VectorType>(II.getType());
928 auto *MaskEltTy = Type::getInt32Ty(II.getContext());
962 auto V1 = II.getArgOperand(0);
968 static Value *simplifyX86vpermilvar(const IntrinsicInst &II,
970 Constant *V = dyn_cast<Constant>(II.getArgOperand(1));
974 auto *VecTy = cast<VectorType>(II.getType());
975 auto *MaskEltTy = Type::getInt32Ty(II.getContext());
1012 auto V1 = II.getArgOperand(0);
1018 static Value *simplifyX86vpermv(const IntrinsicInst &II,
1020 auto *V = dyn_cast<Constant>(II.getArgOperand(1));
1024 auto *VecTy = cast<VectorType>(II.getType());
1025 auto *MaskEltTy = Type::getInt32Ty(II.getContext());
1049 auto V1 = II.getArgOperand(0);
1056 Value *InstCombiner::simplifyMaskedLoad(IntrinsicInst &II) {
1057 Value *LoadPtr = II.getArgOperand(0);
1058 unsigned Alignment = cast<ConstantInt>(II.getArgOperand(1))->getZExtValue();
1062 if (maskIsAllOneOrUndef(II.getArgOperand(2)))
1063 return Builder.CreateAlignedLoad(II.getType(), LoadPtr, Alignment,
1069 LoadPtr, II.getType(), MaybeAlign(Alignment),
1070 II.getModule()->getDataLayout(), &II, nullptr)) {
1071 Value *LI = Builder.CreateAlignedLoad(II.getType(), LoadPtr, Alignment,
1073 return Builder.CreateSelect(II.getArgOperand(2), LI, II.getArgOperand(3));
1082 Instruction *InstCombiner::simplifyMaskedStore(IntrinsicInst &II) {
1083 auto *ConstMask = dyn_cast<Constant>(II.getArgOperand(3));
1089 return eraseInstFromFunction(II);
1093 Value *StorePtr = II.getArgOperand(1);
1095 cast<ConstantInt>(II.getArgOperand(2))->getZExtValue());
1096 return new StoreInst(II.getArgOperand(0), StorePtr, false, Alignment);
1102 if (Value *V = SimplifyDemandedVectorElts(II.getOperand(0),
1104 II.setOperand(0, V);
1105 return &II;
1118 Instruction *InstCombiner::simplifyMaskedGather(IntrinsicInst &II) {
1128 Instruction *InstCombiner::simplifyMaskedScatter(IntrinsicInst &II) {
1129 auto *ConstMask = dyn_cast<Constant>(II.getArgOperand(3));
1135 return eraseInstFromFunction(II);
1140 if (Value *V = SimplifyDemandedVectorElts(II.getOperand(0),
1142 II.setOperand(0, V);
1143 return &II;
1145 if (Value *V = SimplifyDemandedVectorElts(II.getOperand(1),
1147 II.setOperand(1, V);
1148 return &II;
1162 static Instruction *simplifyInvariantGroupIntrinsic(IntrinsicInst &II,
1164 auto *Arg = II.getArgOperand(0);
1172 if (II.getIntrinsicID() == Intrinsic::launder_invariant_group)
1174 else if (II.getIntrinsicID() == Intrinsic::strip_invariant_group)
1180 II.getType()->getPointerAddressSpace())
1181 Result = IC.Builder.CreateAddrSpaceCast(Result, II.getType());
1182 if (Result->getType() != II.getType())
1183 Result = IC.Builder.CreateBitCast(Result, II.getType());
1188 static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombiner &IC) {
1189 assert((II.getIntrinsicID() == Intrinsic::cttz ||
1190 II.getIntrinsicID() == Intrinsic::ctlz) &&
1192 bool IsTZ = II.getIntrinsicID() == Intrinsic::cttz;
1193 Value *Op0 = II.getArgOperand(0);
1199 Function *F = Intrinsic::getDeclaration(II.getModule(), ID, II.getType());
1200 return CallInst::Create(F, {X, II.getArgOperand(1)});
1206 II.setOperand(0, X);
1207 return &II;
1215 II.setOperand(0, X);
1216 return &II;
1220 KnownBits Known = IC.computeKnownBits(Op0, 0, &II);
1234 return IC.replaceInstUsesWith(II, C);
1241 isKnownNonZero(Op0, IC.getDataLayout(), 0, &IC.getAssumptionCache(), &II,
1243 if (!match(II.getArgOperand(1), m_One())) {
1244 II.setOperand(1, IC.Builder.getTrue());
1245 return &II;
1252 if (IT && IT->getBitWidth() != 1 && !II.getMetadata(LLVMContext::MD_range)) {
1256 II.setMetadata(LLVMContext::MD_range,
1257 MDNode::get(II.getContext(), LowAndHigh));
1258 return &II;
1264 static Instruction *foldCtpop(IntrinsicInst &II, InstCombiner &IC) {
1265 assert(II.getIntrinsicID() == Intrinsic::ctpop &&
1267 Value *Op0 = II.getArgOperand(0);
1272 II.setOperand(0, X);
1273 return &II;
1283 IC.computeKnownBits(Op0, Known, 0, &II);
1289 if (IT->getBitWidth() != 1 && !II.getMetadata(LLVMContext::MD_range)) {
1293 II.setMetadata(LLVMContext::MD_range,
1294 MDNode::get(II.getContext(), LowAndHigh));
1295 return &II;
1304 static Instruction *simplifyX86MaskedLoad(IntrinsicInst &II, InstCombiner &IC) {
1305 Value *Ptr = II.getOperand(0);
1306 Value *Mask = II.getOperand(1);
1307 Constant *ZeroVec = Constant::getNullValue(II.getType());
1312 return IC.replaceInstUsesWith(II, ZeroVec);
1324 PointerType *VecPtrTy = PointerType::get(II.getType(), AddrSpace);
1334 return IC.replaceInstUsesWith(II, NewMaskedLoad);
1340 static bool simplifyX86MaskedStore(IntrinsicInst &II, InstCombiner &IC) {
1341 Value *Ptr = II.getOperand(0);
1342 Value *Mask = II.getOperand(1);
1343 Value *Vec = II.getOperand(2);
1348 IC.eraseInstFromFunction(II);
1354 if (II.getIntrinsicID() == Intrinsic::x86_sse2_maskmov_dqu)
1377 IC.eraseInstFromFunction(II);
1406 static Value *simplifyNeonTbl1(const IntrinsicInst &II,
1409 auto *C = dyn_cast<Constant>(II.getArgOperand(1));
1413 auto *VecTy = cast<VectorType>(II.getType());
1435 auto *ShuffleMask = ConstantDataVector::get(II.getContext(),
1437 auto *V1 = II.getArgOperand(0);
1445 static Value *simplifyNeonVld1(const IntrinsicInst &II,
1448 auto *IntrAlign = dyn_cast<ConstantInt>(II.getArgOperand(1));
1459 auto *BCastInst = Builder.CreateBitCast(II.getArgOperand(0),
1460 PointerType::get(II.getType(), 0));
1461 return Builder.CreateAlignedLoad(II.getType(), BCastInst, Alignment);
1508 static Instruction *SimplifyNVVMIntrinsic(IntrinsicInst *II, InstCombiner &IC) {
1560 const SimplifyAction Action = [II]() -> SimplifyAction {
1561 switch (II->getIntrinsicID()) {
1713 II->getFunction()->getFnAttribute("nvptx-f32ftz").getValueAsString() ==
1722 SmallVector<Value *, 4> Args(II->arg_operands());
1725 Type *Tys[] = {II->getArgOperand(0)->getType()};
1727 Intrinsic::getDeclaration(II->getModule(), *Action.IID, Tys), Args);
1732 return BinaryOperator::Create(*Action.BinaryOp, II->getArgOperand(0),
1733 II->getArgOperand(1), II->getName());
1737 return CastInst::Create(*Action.CastOp, II->getArgOperand(0), II->getType(),
1738 II->getName());
1748 Instruction::FDiv, ConstantFP::get(II->getArgOperand(0)->getType(), 1),
1749 II->getArgOperand(0), II->getName());
1775 Instruction *InstCombiner::foldIntrinsicWithOverflowCommon(IntrinsicInst *II) {
1776 WithOverflowInst *WO = cast<WithOverflowInst>(II);
1802 IntrinsicInst *II = dyn_cast<IntrinsicInst>(&CI);
1803 if (!II) return visitCallBase(CI);
1807 if (auto *MI = dyn_cast<AnyMemIntrinsic>(II)) {
1863 if (Changed) return II;
1867 if (II->getType()->isVectorTy()) {
1868 auto VWidth = II->getType()->getVectorNumElements();
1871 if (Value *V = SimplifyDemandedVectorElts(II, AllOnesEltMask, UndefElts)) {
1872 if (V != II)
1873 return replaceInstUsesWith(*II, V);
1874 return II;
1878 if (Instruction *I = SimplifyNVVMIntrinsic(II, *this))
1888 Intrinsic::ID IID = II->getIntrinsicID();
1892 if (Value *V = lowerObjectSizeCall(II, DL, &TLI, /*MustSucceed=*/false))
1896 Value *IIOperand = II->getArgOperand(0);
1910 if (Value *SimplifiedMaskedOp = simplifyMaskedLoad(*II))
1914 return simplifyMaskedStore(*II);
1916 return simplifyMaskedGather(*II);
1918 return simplifyMaskedScatter(*II);
1921 if (auto *SkippedBarrier = simplifyInvariantGroupIntrinsic(*II, *this))
1922 return replaceInstUsesWith(*II, SkippedBarrier);
1925 if (ConstantInt *Power = dyn_cast<ConstantInt>(II->getArgOperand(1))) {
1931 II->getArgOperand(0));
1934 return BinaryOperator::CreateFMul(II->getArgOperand(0),
1935 II->getArgOperand(0));
1941 if (auto *I = foldCttzCtlz(*II, *this))
1946 if (auto *I = foldCtpop(*II, *this))
1952 Value *Op0 = II->getArgOperand(0), *Op1 = II->getArgOperand(1);
1953 Type *Ty = II->getType();
1956 if (match(II->getArgOperand(2), m_Constant(ShAmtC)) &&
1962 II->setArgOperand(2, ModuloC);
1963 return II;
1975 Module *Mod = II->getModule();
1995 Module *Mod = II->getModule();
2002 if (SimplifyDemandedInstructionBits(*II))
2012 if (SimplifyDemandedBits(II, 2, Op2Demanded, Op2Known))
2020 if (Instruction *I = foldIntrinsicWithOverflowCommon(II))
2028 Value *Arg0 = II->getArgOperand(0);
2029 Value *Arg1 = II->getArgOperand(1);
2039 *II, Builder.CreateBinaryIntrinsic(
2052 if (Instruction *I = foldIntrinsicWithOverflowCommon(II))
2057 if (Instruction *I = foldIntrinsicWithOverflowCommon(II))
2061 Value *Arg0 = II->getArgOperand(0);
2062 Value *Arg1 = II->getArgOperand(1);
2072 *II, Builder.CreateBinaryIntrinsic(Intrinsic::sadd_with_overflow,
2086 SaturatingInst *SI = cast<SaturatingInst>(II);
2120 *II, Builder.CreateBinaryIntrinsic(
2153 *II, Builder.CreateBinaryIntrinsic(
2154 IID, X, ConstantInt::get(II->getType(), NewVal)));
2166 Value *Arg0 = II->getArgOperand(0);
2167 Value *Arg1 = II->getArgOperand(1);
2191 Value *NewCall = Builder.CreateBinaryIntrinsic(NewIID, X, Y, II);
2193 FNeg->copyIRFlags(II);
2224 NewCall->copyIRFlags(II);
2225 return replaceInstUsesWith(*II, NewCall);
2233 if (II->isFast()) {
2235 Builder.setFastMathFlags(II->getFastMathFlags());
2236 Value *Mul = Builder.CreateFMul(II->getArgOperand(0),
2237 II->getArgOperand(1));
2238 Value *Add = Builder.CreateFAdd(Mul, II->getArgOperand(2));
2239 Add->takeName(II);
2240 return replaceInstUsesWith(*II, Add);
2244 if (Value *V = SimplifyFMulInst(II->getArgOperand(0), II->getArgOperand(1),
2245 II->getFastMathFlags(),
2246 SQ.getWithInstruction(II))) {
2247 auto *FAdd = BinaryOperator::CreateFAdd(V, II->getArgOperand(2));
2248 FAdd->copyFastMathFlags(II);
2259 Value *Src0 = II->getArgOperand(0);
2260 Value *Src1 = II->getArgOperand(1);
2263 II->setArgOperand(0, X);
2264 II->setArgOperand(1, Y);
2265 return II;
2271 II->setArgOperand(0, X);
2272 II->setArgOperand(1, X);
2273 return II;
2278 if (Value *V = SimplifyFMAFMul(II->getArgOperand(0), II->getArgOperand(1),
2279 II->getFastMathFlags(),
2280 SQ.getWithInstruction(II))) {
2281 auto *FAdd = BinaryOperator::CreateFAdd(V, II->getArgOperand(2));
2282 FAdd->copyFastMathFlags(II);
2289 if (SignBitMustBeZero(II->getArgOperand(1), &TLI)) {
2293 II->getArgOperand(0), II);
2294 return replaceInstUsesWith(*II, Fabs);
2298 if (match(II->getArgOperand(1), m_APFloat(C)) && C->isNegative()) {
2302 II->getArgOperand(0), II);
2303 return replaceInstUsesWith(*II, Builder.CreateFNegFMF(Fabs, II));
2309 if (match(II->getArgOperand(1),
2311 II->setArgOperand(1, SignArg);
2312 return II;
2320 if (match(II->getArgOperand(0),
2322 CallInst *Call0 = Builder.CreateCall(II->getCalledFunction(), {LHS});
2323 CallInst *Call1 = Builder.CreateCall(II->getCalledFunction(), {RHS});
2336 if (match(II->getArgOperand(0), m_OneUse(m_FPExt(m_Value(ExtSrc))))) {
2338 Value *NarrowII = Builder.CreateUnaryIntrinsic(IID, ExtSrc, II);
2339 return new FPExtInst(NarrowII, II->getType());
2346 Value *Src = II->getArgOperand(0);
2350 II->setArgOperand(0, X);
2351 return II;
2357 if (match(II->getArgOperand(0), m_OneUse(m_FNeg(m_Value(X))))) {
2359 Value *NewSin = Builder.CreateUnaryIntrinsic(Intrinsic::sin, X, II);
2361 FNeg->copyFastMathFlags(II);
2369 if (getOrEnforceKnownAlignment(II->getArgOperand(0), 16, DL, II, &AC,
2371 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(0),
2372 PointerType::getUnqual(II->getType()));
2373 return new LoadInst(II->getType(), Ptr);
2379 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(0),
2380 PointerType::getUnqual(II->getType()));
2381 return new LoadInst(II->getType(), Ptr, Twine(""), false, Align::None());
2386 if (getOrEnforceKnownAlignment(II->getArgOperand(1), 16, DL, II, &AC,
2389 PointerType::getUnqual(II->getArgOperand(0)->getType());
2390 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2391 return new StoreInst(II->getArgOperand(0), Ptr);
2397 Type *OpPtrTy = PointerType::getUnqual(II->getArgOperand(0)->getType());
2398 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2399 return new StoreInst(II->getArgOperand(0), Ptr, false, Align::None());
2403 if (getOrEnforceKnownAlignment(II->getArgOperand(0), 16, DL, II, &AC,
2406 II->getType()->getVectorNumElements());
2407 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(0),
2410 return new FPExtInst(Load, II->getType());
2415 if (getOrEnforceKnownAlignment(II->getArgOperand(0), 32, DL, II, &AC,
2417 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(0),
2418 PointerType::getUnqual(II->getType()));
2419 return new LoadInst(II->getType(), Ptr);
2424 if (getOrEnforceKnownAlignment(II->getArgOperand(1), 16, DL, II, &AC,
2427 II->getArgOperand(0)->getType()->getVectorNumElements());
2428 Value *TOp = Builder.CreateFPTrunc(II->getArgOperand(0), VTy);
2430 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2436 if (getOrEnforceKnownAlignment(II->getArgOperand(1), 32, DL, II, &AC,
2439 PointerType::getUnqual(II->getArgOperand(0)->getType());
2440 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2441 return new StoreInst(II->getArgOperand(0), Ptr);
2450 if (auto *C = dyn_cast<ConstantInt>(II->getArgOperand(1))) {
2454 unsigned BitWidth = II->getType()->getIntegerBitWidth();
2457 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), 0));
2459 if (auto *InC = dyn_cast<ConstantInt>(II->getArgOperand(0))) {
2464 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), Result));
2474 if (auto *C = dyn_cast<ConstantInt>(II->getArgOperand(1))) {
2476 unsigned BitWidth = II->getType()->getIntegerBitWidth();
2478 return replaceInstUsesWith(CI, II->getArgOperand(0));
2480 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), 0));
2482 if (auto *InC = dyn_cast<ConstantInt>(II->getArgOperand(0))) {
2485 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), Result));
2492 if (auto *MaskC = dyn_cast<ConstantInt>(II->getArgOperand(1))) {
2494 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), 0));
2496 return replaceInstUsesWith(CI, II->getArgOperand(0));
2498 if (auto *SrcC = dyn_cast<ConstantInt>(II->getArgOperand(0))) {
2515 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), Result));
2521 if (auto *MaskC = dyn_cast<ConstantInt>(II->getArgOperand(1))) {
2523 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), 0));
2525 return replaceInstUsesWith(CI, II->getArgOperand(0));
2527 if (auto *SrcC = dyn_cast<ConstantInt>(II->getArgOperand(0))) {
2544 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), Result));
2551 auto Arg = II->getArgOperand(0);
2553 auto RetType = cast<VectorType>(II->getType());
2565 return replaceInstUsesWith(*II, ConstantAggregateZero::get(RetType));
2578 VectorType::get(Type::getHalfTy(II->getContext()), RetWidth);
2582 return replaceInstUsesWith(*II, VectorFloats);
2587 II->setArgOperand(0, V);
2588 return II;
2619 Value *Arg = II->getArgOperand(0);
2622 II->setArgOperand(0, V);
2623 return II;
2635 if (Value *V = simplifyX86movmsk(*II, Builder))
2636 return replaceInstUsesWith(*II, V);
2670 Value *Arg0 = II->getArgOperand(0);
2671 Value *Arg1 = II->getArgOperand(1);
2674 II->setArgOperand(0, V);
2678 II->setArgOperand(1, V);
2682 return II;
2692 Value *Arg0 = II->getArgOperand(0);
2693 Value *Arg1 = II->getArgOperand(1);
2710 II->setArgOperand(0, A);
2711 II->setArgOperand(1, B);
2712 return II;
2727 if (auto *R = dyn_cast<ConstantInt>(II->getArgOperand(2))) {
2729 Value *Arg0 = II->getArgOperand(0);
2730 Value *Arg1 = II->getArgOperand(1);
2753 return replaceInstUsesWith(*II, V);
2768 if (auto *R = dyn_cast<ConstantInt>(II->getArgOperand(4))) {
2771 Value *Arg0 = II->getArgOperand(0);
2772 Value *Arg1 = II->getArgOperand(1);
2798 Value *Mask = II->getArgOperand(3);
2808 Value *Passthru = Builder.CreateExtractElement(II->getArgOperand(2),
2816 return replaceInstUsesWith(*II, V);
2851 if (Value *V = simplifyX86immShift(*II, Builder))
2852 return replaceInstUsesWith(*II, V);
2882 if (Value *V = simplifyX86immShift(*II, Builder))
2883 return replaceInstUsesWith(*II, V);
2887 Value *Arg1 = II->getArgOperand(1);
2893 II->setArgOperand(1, V);
2894 return II;
2926 if (Value *V = simplifyX86varShift(*II, Builder))
2927 return replaceInstUsesWith(*II, V);
2936 if (Value *V = simplifyX86pack(*II, Builder, true))
2937 return replaceInstUsesWith(*II, V);
2946 if (Value *V = simplifyX86pack(*II, Builder, false))
2947 return replaceInstUsesWith(*II, V);
2953 if (auto *C = dyn_cast<ConstantInt>(II->getArgOperand(2))) {
2957 Value *Arg0 = II->getArgOperand(0);
2958 Value *Arg1 = II->getArgOperand(1);
2966 II->setArgOperand(0, V);
2975 II->setArgOperand(1, V);
2982 return replaceInstUsesWith(*II,
2983 ConstantAggregateZero::get(II->getType()));
2986 return II;
2992 if (Value *V = simplifyX86insertps(*II, Builder))
2993 return replaceInstUsesWith(*II, V);
2997 Value *Op0 = II->getArgOperand(0);
2998 Value *Op1 = II->getArgOperand(1);
3015 if (Value *V = simplifyX86extrq(*II, Op0, CILength, CIIndex, Builder))
3016 return replaceInstUsesWith(*II, V);
3022 II->setArgOperand(0, V);
3026 II->setArgOperand(1, V);
3030 return II;
3037 Value *Op0 = II->getArgOperand(0);
3043 ConstantInt *CILength = dyn_cast<ConstantInt>(II->getArgOperand(1));
3044 ConstantInt *CIIndex = dyn_cast<ConstantInt>(II->getArgOperand(2));
3047 if (Value *V = simplifyX86extrq(*II, Op0, CILength, CIIndex, Builder))
3048 return replaceInstUsesWith(*II, V);
3053 II->setArgOperand(0, V);
3054 return II;
3060 Value *Op0 = II->getArgOperand(0);
3061 Value *Op1 = II->getArgOperand(1);
3079 if (Value *V = simplifyX86insertq(*II, Op0, Op1, Len, Idx, Builder))
3080 return replaceInstUsesWith(*II, V);
3086 II->setArgOperand(0, V);
3087 return II;
3096 Value *Op0 = II->getArgOperand(0);
3097 Value *Op1 = II->getArgOperand(1);
3105 ConstantInt *CILength = dyn_cast<ConstantInt>(II->getArgOperand(2));
3106 ConstantInt *CIIndex = dyn_cast<ConstantInt>(II->getArgOperand(3));
3112 if (Value *V = simplifyX86insertq(*II, Op0, Op1, Len, Idx, Builder))
3113 return replaceInstUsesWith(*II, V);
3120 II->setArgOperand(0, V);
3124 II->setArgOperand(1, V);
3128 return II;
3139 Value *Op0 = II->getArgOperand(0);
3140 Value *Op1 = II->getArgOperand(1);
3141 Value *Mask = II->getArgOperand(2);
3163 II->getType()->getPrimitiveSizeInBits() &&
3167 unsigned NumOperandElts = II->getType()->getVectorNumElements();
3177 return new BitCastInst(Sel, II->getType());
3187 if (Value *V = simplifyX86pshufb(*II, Builder))
3188 return replaceInstUsesWith(*II, V);
3197 if (Value *V = simplifyX86vpermilvar(*II, Builder))
3198 return replaceInstUsesWith(*II, V);
3215 if (Value *V = simplifyX86vpermv(*II, Builder))
3216 return replaceInstUsesWith(*II, V);
3227 if (Instruction *I = simplifyX86MaskedLoad(*II, *this))
3240 if (simplifyX86MaskedStore(*II, *this))
3246 if (Value *V = simplifyX86addcarry(*II, Builder))
3247 return replaceInstUsesWith(*II, V);
3257 if (Constant *Mask = dyn_cast<Constant>(II->getArgOperand(2))) {
3273 Value *Op0 = Builder.CreateBitCast(II->getArgOperand(0),
3275 Value *Op1 = Builder.CreateBitCast(II->getArgOperand(1),
3310 unsigned MemAlign = getKnownAlignment(II->getArgOperand(0),
3311 DL, II, &AC, &DT);
3312 if (Value *V = simplifyNeonVld1(*II, MemAlign, Builder))
3313 return replaceInstUsesWith(*II, V);
3331 getKnownAlignment(II->getArgOperand(0), DL, II, &AC, &DT);
3332 unsigned AlignArg = II->getNumArgOperands() - 1;
3333 ConstantInt *IntrAlign = dyn_cast<ConstantInt>(II->getArgOperand(AlignArg));
3335 II->setArgOperand(AlignArg,
3336 ConstantInt::get(Type::getInt32Ty(II->getContext()),
3338 return II;
3345 if (Value *V = simplifyNeonTbl1(*II, Builder))
3346 return replaceInstUsesWith(*II, V);
3353 Value *Arg0 = II->getArgOperand(0);
3354 Value *Arg1 = II->getArgOperand(1);
3358 return replaceInstUsesWith(CI, ConstantAggregateZero::get(II->getType()));
3364 VectorType *NewVT = cast<VectorType>(II->getType());
3382 return CastInst::CreateIntegerCast(Arg0, II->getType(),
3391 Value *DataArg = II->getArgOperand(0);
3392 Value *KeyArg = II->getArgOperand(1);
3398 II->setArgOperand(0, Data);
3399 II->setArgOperand(1, Key);
3400 return II;
3405 Value *Arg = II->getArgOperand(0);
3408 II->getType() == ArgArg->getType())
3409 return replaceInstUsesWith(*II, ArgArg);
3414 II->getType() == ArgArg->getType()) {
3418 II->getType()->getVectorNumElements(), Builder.getTrue());
3424 if (SimplifyDemandedBits(II, 0, APInt::getLowBitsSet(32, 16),
3426 return II;
3430 Value *Arg = II->getArgOperand(0);
3433 return replaceInstUsesWith(*II, ArgArg);
3434 if (!II->getMetadata(LLVMContext::MD_range)) {
3435 Type *IntTy32 = Type::getInt32Ty(II->getContext());
3440 II->setMetadata(LLVMContext::MD_range, MDNode::get(II->getContext(), M));
3441 return II;
3448 (II->getIntrinsicID() == Intrinsic::arm_mve_vadc_predicated) ? 3 : 2;
3449 assert(II->getArgOperand(CarryOp)->getType()->getScalarSizeInBits() == 32 &&
3453 if (SimplifyDemandedBits(II, CarryOp, APInt::getOneBitSet(32, 29),
3455 return II;
3459 Value *Src = II->getArgOperand(0);
3473 return replaceInstUsesWith(CI, ConstantFP::get(II->getContext(), Val));
3479 Value *Src = II->getArgOperand(0);
3488 Value *Src = II->getArgOperand(0);
3495 return replaceInstUsesWith(CI, ConstantFP::get(II->getContext(),
3503 return replaceInstUsesWith(CI, ConstantInt::get(II->getType(), Exp));
3507 return replaceInstUsesWith(CI, UndefValue::get(II->getType()));
3528 Value *Src0 = II->getArgOperand(0);
3529 Value *Src1 = II->getArgOperand(1);
3533 return replaceInstUsesWith(*II, UndefValue::get(II->getType()));
3536 return replaceInstUsesWith(*II, ConstantInt::get(II->getType(), false));
3544 return replaceInstUsesWith(*II, ConstantInt::get(II->getType(), true));
3547 return replaceInstUsesWith(*II, ConstantInt::get(II->getType(), false));
3552 FCmp->takeName(II);
3553 return replaceInstUsesWith(*II, FCmp);
3561 FCmp->takeName(II);
3562 return replaceInstUsesWith(*II, FCmp);
3567 II->setArgOperand(1, ConstantInt::get(Src1->getType(),
3569 return II;
3575 return replaceInstUsesWith(*II, UndefValue::get(II->getType()));
3579 CallInst *NewCall = Builder.CreateCall(II->getCalledFunction(),
3583 NewCall->takeName(II);
3584 return replaceInstUsesWith(*II, NewCall);
3604 return replaceInstUsesWith(*II, ConstantInt::get(II->getType(), Result));
3607 Value *Src0 = II->getArgOperand(0);
3608 Value *Src1 = II->getArgOperand(1);
3612 = II->getType()->getScalarType()->getFltSemantics();
3620 ConstantFP::get(II->getContext(), Val0),
3621 ConstantFP::get(II->getContext(), Val1) });
3622 return replaceInstUsesWith(*II, Folded);
3627 return replaceInstUsesWith(*II, UndefValue::get(II->getType()));
3635 Value *Src0 = II->getArgOperand(0);
3636 Value *Src1 = II->getArgOperand(1);
3639 return replaceInstUsesWith(*II, UndefValue::get(II->getType()));
3646 Value *Src = II->getArgOperand(0);
3648 return replaceInstUsesWith(*II, Src);
3651 Type *Ty = II->getType();
3654 ConstantInt *CWidth = dyn_cast<ConstantInt>(II->getArgOperand(2));
3658 return replaceInstUsesWith(*II, ConstantInt::getNullValue(Ty));
3662 II->setArgOperand(2, ConstantInt::get(CWidth->getType(),
3664 return II;
3669 ConstantInt *COffset = dyn_cast<ConstantInt>(II->getArgOperand(1));
3673 II->setArgOperand(1, ConstantInt::get(COffset->getType(),
3675 return II;
3695 RightShift->takeName(II);
3696 return replaceInstUsesWith(*II, RightShift);
3702 RightShift->takeName(II);
3703 return replaceInstUsesWith(*II, RightShift);
3707 ConstantInt *En = cast<ConstantInt>(II->getArgOperand(1));
3717 Value *Src = II->getArgOperand(I + 2);
3719 II->setArgOperand(I + 2, UndefValue::get(Src->getType()));
3726 return II;
3734 Value *Src0 = II->getArgOperand(0);
3735 Value *Src1 = II->getArgOperand(1);
3736 Value *Src2 = II->getArgOperand(2);
3751 NewCall->copyFastMathFlags(II);
3752 NewCall->takeName(II);
3753 return replaceInstUsesWith(*II, NewCall);
3776 II->setArgOperand(0, Src0);
3777 II->setArgOperand(1, Src1);
3778 II->setArgOperand(2, Src2);
3779 return II;
3787 return replaceInstUsesWith(*II,
3797 const ConstantInt *CC = cast<ConstantInt>(II->getArgOperand(2));
3807 Value *Src0 = II->getArgOperand(0);
3808 Value *Src1 = II->getArgOperand(1);
3815 *II, ConstantExpr::getSExt(CCmp, II->getType()));
3824 II->getModule(), Intrinsic::read_register, II->getType());
3825 Metadata *MDArgs[] = {MDString::get(II->getContext(), "exec")};
3826 MDNode *MD = MDNode::get(II->getContext(), MDArgs);
3827 Value *Args[] = {MetadataAsValue::get(II->getContext(), MD)};
3831 NewCall->takeName(II);
3832 return replaceInstUsesWith(*II, NewCall);
3838 II->setArgOperand(0, Src1);
3839 II->setArgOperand(1, Src0);
3840 II->setArgOperand(2, ConstantInt::get(CC->getType(),
3842 return II;
3858 II->setArgOperand(1, ConstantInt::getNullValue(Src1->getType()));
3859 II->setArgOperand(2, ConstantInt::get(CC->getType(), CmpInst::ICMP_NE));
3860 return II;
3919 Intrinsic::getDeclaration(II->getModule(), NewIID,
3920 { II->getType(),
3925 NewCall->takeName(II);
3926 return replaceInstUsesWith(*II, NewCall);
3933 if (!isa<Constant>(II->getArgOperand(0)))
3936 return replaceInstUsesWith(*II, II->getArgOperand(0));
3939 const ConstantInt *C = dyn_cast<ConstantInt>(II->getArgOperand(0));
3947 Value *Old = II->getArgOperand(0);
3949 auto BC = cast<ConstantInt>(II->getArgOperand(5));
3950 auto RM = cast<ConstantInt>(II->getArgOperand(3));
3951 auto BM = cast<ConstantInt>(II->getArgOperand(4));
3959 II->setOperand(0, UndefValue::get(Old->getType()));
3960 return II;
3965 if (Constant *C = dyn_cast<Constant>(II->getArgOperand(0)))
3966 return replaceInstUsesWith(*II, C);
3970 Value *Src = II->getArgOperand(0);
3972 if (SrcInst && SrcInst->getParent() != II->getParent())
3978 return replaceInstUsesWith(*II, Src);
3983 return replaceInstUsesWith(*II, Src);
3987 m_Value(), m_Specific(II->getArgOperand(1)))))
3988 return replaceInstUsesWith(*II, Src);
3996 if (IntrinsicInst *SS = dyn_cast<IntrinsicInst>(II->getArgOperand(0))) {
3999 if (SS->getNextNonDebugInstruction() == II) {
4007 BasicBlock::iterator BI(II);
4008 Instruction *TI = II->getParent()->getTerminator();
4046 if (II->getFunction()->hasFnAttribute(Attribute::SanitizeAddress) ||
4047 II->getFunction()->hasFnAttribute(Attribute::SanitizeMemory) ||
4048 II->getFunction()->hasFnAttribute(Attribute::SanitizeHWAddress))
4051 if (removeTriviallyEmptyRange(*II, Intrinsic::lifetime_start,
4056 Value *IIOperand = II->getArgOperand(0);
4060 Instruction *Next = II->getNextNonDebugInstruction();
4067 FunctionType *AssumeIntrinsicTy = II->getFunctionType();
4068 Value *AssumeIntrinsic = II->getCalledValue();
4071 Builder.CreateCall(AssumeIntrinsicTy, AssumeIntrinsic, A, II->getName());
4072 Builder.CreateCall(AssumeIntrinsicTy, AssumeIntrinsic, B, II->getName());
4073 return eraseInstFromFunction(*II);
4078 Builder.CreateNot(A), II->getName());
4080 Builder.CreateNot(B), II->getName());
4081 return eraseInstFromFunction(*II);
4091 isValidAssumeForContext(II, LHS, &DT)) {
4092 MDNode *MD = MDNode::get(II->getContext(), None);
4094 return eraseInstFromFunction(*II);
4103 computeKnownBits(IIOperand, Known, 0, II);
4105 return eraseInstFromFunction(*II);
4109 AC.updateAffectedValues(II);
4113 auto &GCR = *cast<GCRelocateInst>(II);
4120 II->setOperand(2, ConstantInt::get(OpIntTy, GCR.getBasePtrIndex()));
4121 return II;
4131 if (II->use_empty())
4132 return eraseInstFromFunction(*II);
4140 return replaceInstUsesWith(*II, UndefValue::get(II->getType()));
4142 if (auto *PT = dyn_cast<PointerType>(II->getType())) {
4148 return replaceInstUsesWith(*II, ConstantPointerNull::get(PT));
4151 if (!II->hasRetAttr(Attribute::NonNull) &&
4152 isKnownNonZero(DerivedPtr, DL, 0, &AC, II, &DT)) {
4153 II->addAttribute(AttributeList::ReturnIndex, Attribute::NonNull);
4154 return II;
4169 Instruction *NextInst = II->getNextNonDebugInstruction();
4179 Value *CurrCond = II->getArgOperand(0);
4184 Instruction *MoveI = II->getNextNonDebugInstruction();
4188 Temp->moveBefore(II);
4190 II->setArgOperand(0, Builder.CreateAnd(CurrCond, NextCond));
4193 return II;
4198 return visitCallBase(*II);
4212 Instruction *InstCombiner::visitInvokeInst(InvokeInst &II) {
4213 return visitCallBase(II);
4287 IntrinsicInst *II = dyn_cast<IntrinsicInst>(U);
4288 if (!II)
4290 if (II->getIntrinsicID() == Intrinsic::init_trampoline) {
4294 InitTrampoline = II;
4297 if (II->getIntrinsicID() == Intrinsic::adjust_trampoline)
4322 if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
4323 if (II->getIntrinsicID() == Intrinsic::init_trampoline &&
4324 II->getOperand(0) == TrampMem)
4325 return II;
4490 if (IntrinsicInst *II = findInitTrampoline(Callee))
4491 return transformCallThroughTrampoline(Call, *II);
4597 if (InvokeInst *II = dyn_cast<InvokeInst>(Caller))
4598 for (User *U : II->users())
4600 if (PN->getParent() == II->getNormalDest() ||
4601 PN->getParent() == II->getUnwindDest())
4762 if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
4763 NewCall = Builder.CreateInvoke(Callee, II->getNormalDest(),
4764 II->getUnwindDest(), Args, OpBundles);
4793 if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
4794 BasicBlock::iterator I = II->getNormalDest()->getFirstInsertionPt();
4941 if (InvokeInst *II = dyn_cast<InvokeInst>(&Call)) {
4943 II->getNormalDest(), II->getUnwindDest(),
4945 cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv());