46 #define DEBUG_TYPE "instsimplify"
50 STATISTIC(NumExpand,
"Number of expansions");
51 STATISTIC(NumReassoc,
"Number of reassociations");
77 if (
auto *BO = dyn_cast<BinaryOperator>(
Cond))
78 BinOpCode = BO->getOpcode();
83 if (BinOpCode == BinaryOperator::Or) {
85 }
else if (BinOpCode == BinaryOperator::And) {
107 Pred1 != Pred2 || Pred1 != ExpectedPred)
131 CmpInst *Cmp = dyn_cast<CmpInst>(V);
135 Value *CLHS = Cmp->getOperand(0), *CRHS = Cmp->getOperand(1);
136 if (CPred == Pred && CLHS == LHS && CRHS == RHS)
152 if (SimplifiedCmp ==
Cond) {
160 return SimplifiedCmp;
167 unsigned MaxRecurse) {
176 unsigned MaxRecurse) {
186 unsigned MaxRecurse) {
217 if (!
I->getParent() || !
P->getParent() || !
I->getFunction())
226 if (
I->getParent() == &
I->getFunction()->getEntryBlock() &&
227 !isa<InvokeInst>(
I) && !isa<CallBrInst>(
I))
239 auto *
B = dyn_cast<BinaryOperator>(V);
240 if (!
B ||
B->getOpcode() != OpcodeToExpand)
242 Value *B0 =
B->getOperand(0), *
B1 =
B->getOperand(1);
253 if ((L == B0 && R ==
B1) ||
274 unsigned MaxRecurse) {
291 unsigned MaxRecurse) {
311 if (V ==
B)
return LHS;
330 if (V ==
B)
return RHS;
353 if (V == A)
return LHS;
372 if (V ==
C)
return RHS;
390 unsigned MaxRecurse) {
396 if (isa<SelectInst>(LHS)) {
397 SI = cast<SelectInst>(LHS);
399 assert(isa<SelectInst>(RHS) &&
"No select instruction operand!");
400 SI = cast<SelectInst>(RHS);
427 if (TV ==
SI->getTrueValue() && FV ==
SI->getFalseValue())
433 if ((FV && !TV) || (TV && !FV)) {
441 Value *UnsimplifiedBranch = FV ?
SI->getTrueValue() :
SI->getFalseValue();
442 Value *UnsimplifiedLHS =
SI == LHS ? UnsimplifiedBranch : LHS;
443 Value *UnsimplifiedRHS =
SI == LHS ? RHS : UnsimplifiedBranch;
444 if (
Simplified->getOperand(0) == UnsimplifiedLHS &&
448 Simplified->getOperand(1) == UnsimplifiedLHS &&
468 unsigned MaxRecurse) {
474 if (!isa<SelectInst>(LHS)) {
478 assert(isa<SelectInst>(LHS) &&
"Not comparing with a select instruction!");
481 Value *TV =
SI->getTrueValue();
482 Value *FV =
SI->getFalseValue();
514 unsigned MaxRecurse) {
520 if (isa<PHINode>(LHS)) {
521 PI = cast<PHINode>(LHS);
526 assert(isa<PHINode>(RHS) &&
"No PHI instruction operand!");
527 PI = cast<PHINode>(RHS);
534 Value *CommonValue =
nullptr;
537 if (Incoming == PI)
continue;
538 Value *V = PI == LHS ?
543 if (!V || (CommonValue && V != CommonValue))
562 if (!isa<PHINode>(LHS)) {
566 assert(isa<PHINode>(LHS) &&
"Not comparing with a phi instruction!");
567 PHINode *PI = cast<PHINode>(LHS);
574 Value *CommonValue =
nullptr;
579 if (Incoming == PI)
continue;
587 if (!V || (CommonValue && V != CommonValue))
598 if (
auto *CLHS = dyn_cast<Constant>(Op0)) {
599 if (
auto *CRHS = dyn_cast<Constant>(Op1))
691 bool AllowNonInbounds =
false) {
694 Type *IntIdxTy =
DL.getIndexType(V->
getType())->getScalarType();
700 IntIdxTy =
DL.getIndexType(V->
getType())->getScalarType();
768 Value *
X =
nullptr, *
Y =
nullptr, *Z = Op1;
826 if (
X->getType() ==
Y->getType())
866 unsigned MaxRecurse) {
904 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1))
911 if (isa<PHINode>(Op0) || isa<PHINode>(Op1))
942 auto *Op1C = dyn_cast<Constant>(Op1);
943 auto *VTy = dyn_cast<FixedVectorType>(Ty);
945 unsigned NumElts = VTy->getNumElements();
946 for (
unsigned i = 0;
i != NumElts; ++
i) {
987 Constant *
C = dyn_cast_or_null<Constant>(V);
988 return (
C &&
C->isAllOnesValue());
994 unsigned MaxRecurse,
bool IsSigned) {
1007 Type *Ty =
X->getType();
1023 if (
C->isMinSignedValue())
1052 bool IsSigned = Opcode == Instruction::SDiv;
1057 auto *
Mul = cast<OverflowingBinaryOperator>(Op0);
1078 (void)
C1->getValue().umul_ov(C2->
getValue(), Overflow);
1085 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1))
1091 if (isa<PHINode>(Op0) || isa<PHINode>(Op1))
1095 if (
isDivZero(Op0, Op1, Q, MaxRecurse, IsSigned))
1111 if ((Opcode == Instruction::SRem &&
1113 (Opcode == Instruction::URem &&
1119 ((Opcode == Instruction::SRem &&
1121 (Opcode == Instruction::URem &&
1127 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1))
1133 if (isa<PHINode>(Op0) || isa<PHINode>(Op1))
1138 if (
isDivZero(Op0, Op1, Q, MaxRecurse, Opcode == Instruction::SRem))
1147 unsigned MaxRecurse) {
1152 return simplifyDiv(Instruction::SDiv, Op0, Op1, Q, MaxRecurse);
1162 unsigned MaxRecurse) {
1163 return simplifyDiv(Instruction::UDiv, Op0, Op1, Q, MaxRecurse);
1173 unsigned MaxRecurse) {
1184 return simplifyRem(Instruction::SRem, Op0, Op1, Q, MaxRecurse);
1194 unsigned MaxRecurse) {
1195 return simplifyRem(Instruction::URem, Op0, Op1, Q, MaxRecurse);
1204 Constant *
C = dyn_cast<Constant>(Amount);
1214 if (CI->getValue().uge(CI->getType()->getScalarSizeInBits()))
1218 if (isa<ConstantVector>(
C) || isa<ConstantDataVector>(
C)) {
1219 for (
unsigned I = 0,
1220 E = cast<FixedVectorType>(
C->getType())->getNumElements();
1234 unsigned MaxRecurse) {
1256 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1))
1262 if (isa<PHINode>(Op0) || isa<PHINode>(Op1))
1280 assert(Opcode == Instruction::Shl &&
"Expected shl for nsw instruction");
1300 unsigned MaxRecurse) {
1317 if (Op0Known.
One[0])
1329 SimplifyShift(Instruction::Shl, Op0, Op1, isNSW, Q, MaxRecurse))
1376 const APInt *ShRAmt, *ShLAmt;
1379 *ShRAmt == *ShLAmt) {
1383 if (ShRAmt->
uge(EffWidthY))
1429 ICmpInst *UnsignedICmp,
bool IsAnd,
1443 if (
match(UnsignedICmp,
1461 return IsAnd ? UnsignedICmp : ZeroICmp;
1467 return IsAnd ? ZeroICmp : UnsignedICmp;
1473 if (
match(UnsignedICmp,
1478 return UnsignedICmp;
1482 return UnsignedICmp;
1489 else if (
match(UnsignedICmp,
1500 return IsAnd ? ZeroICmp : UnsignedICmp;
1506 return IsAnd ? UnsignedICmp : ZeroICmp;
1516 return IsAnd ? UnsignedICmp : ZeroICmp;
1521 return IsAnd ? ZeroICmp : UnsignedICmp;
1606 if (IsAnd && Range0.intersectWith(Range1).isEmptySet())
1611 if (!IsAnd && Range0.unionWith(Range1).isFullSet())
1619 if (Range0.contains(Range1))
1620 return IsAnd ? Cmp1 : Cmp0;
1621 if (Range1.contains(Range0))
1622 return IsAnd ? Cmp0 : Cmp1;
1676 auto *AddInst = cast<OverflowingBinaryOperator>(Op0->
getOperand(0));
1677 if (AddInst->getOperand(1) != Op1->
getOperand(1))
1684 const APInt Delta = *
C1 - *C0;
1685 if (C0->isStrictlyPositive()) {
1699 if (C0->getBoolValue() && isNUW) {
1737 MinMaxC = HasNotOp ? ~*
C : *
C;
1738 else if (isa<ConstantPointerNull>(Cmp0->
getOperand(1)))
1812 auto *AddInst = cast<BinaryOperator>(Op0->
getOperand(0));
1813 if (AddInst->getOperand(1) != Op1->
getOperand(1))
1820 const APInt Delta = *
C1 - *C0;
1821 if (C0->isStrictlyPositive()) {
1835 if (C0->getBoolValue() && isNUW) {
1917 auto *Cast0 = dyn_cast<CastInst>(Op0);
1918 auto *Cast1 = dyn_cast<CastInst>(Op1);
1919 if (Cast0 && Cast1 && Cast0->getOpcode() == Cast1->getOpcode() &&
1920 Cast0->getSrcTy() == Cast1->getSrcTy()) {
1921 Op0 = Cast0->getOperand(0);
1922 Op1 = Cast1->getOperand(0);
1926 auto *ICmp0 = dyn_cast<ICmpInst>(Op0);
1927 auto *ICmp1 = dyn_cast<ICmpInst>(Op1);
1932 auto *FCmp0 = dyn_cast<FCmpInst>(Op0);
1933 auto *FCmp1 = dyn_cast<FCmpInst>(Op1);
1944 if (
auto *
C = dyn_cast<Constant>(V))
1955 auto *Extract = dyn_cast<ExtractValueInst>(Op1);
1957 if (!Extract || !Extract->getIndices().equals(1))
1959 Value *Agg = Extract->getAggregateOperand();
1962 m_Intrinsic<Intrinsic::smul_with_overflow>())))
1984 Pred != ICmpInst::Predicate::ICMP_NE)
2008 Pred != ICmpInst::Predicate::ICMP_EQ)
2048 unsigned MaxRecurse) {
2092 (~(*
Mask)).
lshr(*ShAmt).isNullValue())
2098 (~(*
Mask)).
shl(*ShAmt).isNullValue())
2141 Instruction::Or, Q, MaxRecurse))
2146 Instruction::Xor, Q, MaxRecurse))
2149 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) {
2167 if (isa<PHINode>(Op0) || isa<PHINode>(Op1))
2191 if (EffWidthY <= ShftCnt) {
2216 unsigned MaxRecurse) {
2331 Instruction::And, Q, MaxRecurse))
2334 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) {
2378 if (isa<PHINode>(Op0) || isa<PHINode>(Op1))
2392 unsigned MaxRecurse) {
2450 CmpInst *Cmp = dyn_cast<CmpInst>(
SI->getCondition());
2453 Value *CmpLHS = Cmp->getOperand(0), *CmpRHS = Cmp->getOperand(1);
2454 if (Pred == Cmp->getPredicate() && LHS == CmpLHS && RHS == CmpRHS)
2457 LHS == CmpRHS && RHS == CmpLHS)
2577 if (isa<AllocaInst>(LHS) &&
2578 (isa<AllocaInst>(RHS) || isa<GlobalVariable>(RHS))) {
2579 ConstantInt *LHSOffsetCI = dyn_cast<ConstantInt>(LHSOffset);
2580 ConstantInt *RHSOffsetCI = dyn_cast<ConstantInt>(RHSOffset);
2581 uint64_t LHSSize, RHSSize;
2585 if (LHSOffsetCI && RHSOffsetCI &&
2592 LHSOffsetValue.
ult(LHSSize) &&
2593 RHSOffsetValue.
ult(RHSSize)) {
2601 if (!cast<PointerType>(LHS->
getType())->isEmptyTy() &&
2602 !cast<PointerType>(RHS->
getType())->isEmptyTy() &&
2642 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(V))
2643 return AI->getParent() && AI->getFunction() && AI->isStaticAlloca();
2645 return (GV->hasLocalLinkage() || GV->hasHiddenVisibility() ||
2646 GV->hasProtectedVisibility() || GV->hasGlobalUnnamedAddr()) &&
2647 !GV->isThreadLocal();
2648 if (
const Argument *A = dyn_cast<Argument>(V))
2649 return A->hasByValAttr();
2654 if ((IsNAC(LHSUObjs) && IsAllocDisjoint(RHSUObjs)) ||
2655 (IsNAC(RHSUObjs) && IsAllocDisjoint(LHSUObjs)))
2857 *MulC != 0 &&
C->
urem(*MulC) != 0) ||
2859 *MulC != 0 &&
C->
srem(*MulC) != 0)))
2960 (
APInt(
C1->getBitWidth(), 1) << *
C1).ule(*C2))) {
3001 return (
C1->slt(*C2) &&
C1->isNonNegative()) ||
3002 (C2->
slt(*
C1) &&
C1->isNonPositive());
3011 unsigned MaxRecurse) {
3014 if (MaxRecurse && (LBO || RBO)) {
3016 Value *A =
nullptr, *
B =
nullptr, *
C =
nullptr, *
D =
nullptr;
3018 bool NoLHSWrapProblem =
false, NoRHSWrapProblem =
false;
3041 if ((A == RHS ||
B == RHS) && NoLHSWrapProblem)
3048 if ((
C == LHS ||
D == LHS) && NoRHSWrapProblem)
3051 C == LHS ?
D :
C, Q, MaxRecurse - 1))
3055 bool CanSimplify = (NoLHSWrapProblem && NoRHSWrapProblem) ||
3057 if (A &&
C && (A ==
C || A ==
D ||
B ==
C ||
B ==
D) && CanSimplify) {
3064 }
else if (A ==
D) {
3068 }
else if (
B ==
C) {
3096 if (
C->isStrictlyPositive()) {
3102 if (
C->isNonNegative()) {
3150 case Instruction::UDiv:
3151 case Instruction::LShr:
3159 case Instruction::SDiv:
3167 case Instruction::AShr:
3174 case Instruction::Shl: {
3195 unsigned MaxRecurse) {
3209 (A == LHS ||
B == LHS)) {
3216 (A == RHS ||
B == RHS)) {
3224 (A == LHS ||
B == LHS)) {
3283 (A == LHS ||
B == LHS)) {
3290 (A == RHS ||
B == RHS)) {
3298 (A == LHS ||
B == LHS)) {
3357 (A ==
C || A ==
D ||
B ==
C ||
B ==
D)) {
3366 (A ==
C || A ==
D ||
B ==
C ||
B ==
D)) {
3385 for (
Value *AssumeBaseOp : {LHS, RHS}) {
3390 CallInst *Assume = cast<CallInst>(AssumeVH);
3409 if (
Constant *CLHS = dyn_cast<Constant>(LHS)) {
3410 if (
Constant *CRHS = dyn_cast<Constant>(RHS))
3417 assert(!isa<UndefValue>(LHS) &&
"Unexpected icmp undef,%X");
3445 if (isa<Instruction>(RHS) && isa<Instruction>(LHS)) {
3446 auto RHS_Instr = cast<Instruction>(RHS);
3447 auto LHS_Instr = cast<Instruction>(LHS);
3452 *RHS_Instr->getMetadata(LLVMContext::MD_range));
3454 *LHS_Instr->getMetadata(LLVMContext::MD_range));
3456 if (LHS_CR.icmp(Pred, RHS_CR))
3465 if (isa<CastInst>(LHS) && (isa<Constant>(RHS) || isa<CastInst>(RHS))) {
3473 if (MaxRecurse && isa<PtrToIntInst>(LI) &&
3475 if (
Constant *RHSC = dyn_cast<Constant>(RHS)) {
3481 }
else if (
PtrToIntInst *RI = dyn_cast<PtrToIntInst>(RHS)) {
3482 if (RI->getOperand(0)->getType() == SrcTy)
3490 if (isa<ZExtInst>(LHS)) {
3493 if (
ZExtInst *RI = dyn_cast<ZExtInst>(RHS)) {
3494 if (MaxRecurse && SrcTy == RI->getOperand(0)->getType())
3497 SrcOp, RI->getOperand(0), Q,
3502 else if (
SExtInst *RI = dyn_cast<SExtInst>(RHS)) {
3503 if (
SrcOp == RI->getOperand(0)) {
3512 else if (
ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {
3520 if (RExt == CI && MaxRecurse)
3522 SrcOp, Trunc, Q, MaxRecurse-1))
3545 return CI->getValue().isNegative() ?
3551 return CI->getValue().isNegative() ?
3559 if (isa<SExtInst>(LHS)) {
3562 if (
SExtInst *RI = dyn_cast<SExtInst>(RHS)) {
3563 if (MaxRecurse && SrcTy == RI->getOperand(0)->getType())
3570 else if (
ZExtInst *RI = dyn_cast<ZExtInst>(RHS)) {
3571 if (
SrcOp == RI->getOperand(0)) {
3580 else if (
ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {
3588 if (RExt == CI && MaxRecurse)
3606 return CI->getValue().isNegative() ?
3611 return CI->getValue().isNegative() ?
3663 if (
auto *CLHS = dyn_cast<PtrToIntOperator>(LHS))
3664 if (
auto *CRHS = dyn_cast<PtrToIntOperator>(RHS))
3670 CRHS->getPointerOperand(), Q))
3674 if (
GEPOperator *GRHS = dyn_cast<GEPOperator>(RHS)) {
3675 if (GLHS->getPointerOperand() == GRHS->getPointerOperand() &&
3676 GLHS->hasAllConstantIndices() && GRHS->hasAllConstantIndices() &&
3678 (GLHS->isInBounds() && GRHS->isInBounds() &&
3686 GLHS->getSourceElementType(), Null, IndicesLHS);
3690 GLHS->getSourceElementType(), Null, IndicesRHS);
3699 if (isa<SelectInst>(LHS) || isa<SelectInst>(RHS))
3705 if (isa<PHINode>(LHS) || isa<PHINode>(RHS))
3721 unsigned MaxRecurse) {
3725 if (
Constant *CLHS = dyn_cast<Constant>(LHS)) {
3726 if (
Constant *CRHS = dyn_cast<Constant>(RHS))
3749 "Comparison must be either ordered or unordered");
3775 if (
C->isInfinity()) {
3776 if (
C->isNegative()) {
3815 if (
C->isNegative() && !
C->isNegZero()) {
3816 assert(!
C->isNaN() &&
"Unexpected NaN constant!");
3903 if (isa<SelectInst>(LHS) || isa<SelectInst>(RHS))
3909 if (isa<PHINode>(LHS) || isa<PHINode>(RHS))
3923 bool AllowRefinement,
3924 unsigned MaxRecurse) {
3930 if (isa<Constant>(
Op))
3933 auto *
I = dyn_cast<Instruction>(V);
3940 [&](
Value *V) { return V == Op ? RepOp : V; });
3942 if (!AllowRefinement) {
3947 if (
auto *BO = dyn_cast<BinaryOperator>(
I)) {
3948 unsigned Opcode = BO->getOpcode();
3957 if ((Opcode == Instruction::And || Opcode == Instruction::Or) &&
3958 NewOps[0] == NewOps[1])
3962 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I)) {
3964 if (NewOps.size() == 2 &&
match(NewOps[1],
m_Zero()) &&
3968 }
else if (MaxRecurse) {
3982 if (
auto *
B = dyn_cast<BinaryOperator>(
I))
3983 return PreventSelfSimplify(
SimplifyBinOp(
B->getOpcode(), NewOps[0],
3984 NewOps[1], Q, MaxRecurse - 1));
3988 NewOps[1], Q, MaxRecurse - 1));
3990 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I))
3992 NewOps, Q, MaxRecurse - 1));
3994 if (isa<SelectInst>(
I))
3995 return PreventSelfSimplify(
4004 for (
Value *NewOp : NewOps) {
4005 if (
Constant *ConstOp = dyn_cast<Constant>(NewOp))
4006 ConstOps.push_back(ConstOp);
4025 ConstOps[1], Q.
DL, Q.
TLI);
4027 if (
LoadInst *LI = dyn_cast<LoadInst>(
I))
4028 if (!LI->isVolatile())
4036 bool AllowRefinement) {
4044 const APInt *
Y,
bool TrueWhenUnset) {
4059 if (
Y->isPowerOf2()) {
4094 unsigned MaxRecurse) {
4096 Value *CmpLHS, *CmpRHS;
4160 false, MaxRecurse) ==
4163 false, MaxRecurse) ==
4167 true, MaxRecurse) ==
4170 true, MaxRecurse) ==
4190 bool HasNoSignedZeros = Q.
CxtI && isa<FPMathOperator>(Q.
CxtI) &&
4213 if (
auto *CondC = dyn_cast<Constant>(
Cond)) {
4214 if (
auto *TrueC = dyn_cast<Constant>(
TrueVal))
4215 if (
auto *FalseC = dyn_cast<Constant>(
FalseVal))
4225 if (CondC->isAllOnesValue())
4228 if (CondC->isNullValue())
4233 assert(
Cond->getType()->isIntOrIntVectorTy(1) &&
4234 "Select must have bool or bool vector condition");
4236 "Select must have same types for true/false ops");
4258 if (isa<FixedVectorType>(
TrueVal->getType()) &&
4262 cast<FixedVectorType>(TrueC->
getType())->getNumElements();
4264 for (
unsigned i = 0;
i != NumElts; ++
i) {
4268 if (!TEltC || !FEltC)
4274 NewC.push_back(TEltC);
4277 NewC.push_back(FEltC);
4280 NewC.push_back(TEltC);
4284 if (NewC.size() == NumElts)
4316 cast<PointerType>(Ops[0]->
getType()->getScalarType())->getAddressSpace();
4319 if (Ops.
size() == 1)
4328 if (
VectorType *VT = dyn_cast<VectorType>(
Op->getType())) {
4336 if (
any_of(Ops, [](
const auto *V) {
return isa<PoisonValue>(V); }))
4342 bool IsScalableVec =
4343 isa<ScalableVectorType>(SrcTy) ||
any_of(Ops, [](
const Value *V) {
4344 return isa<ScalableVectorType>(V->
getType());
4347 if (Ops.size() == 2) {
4349 if (
match(Ops[1],
m_Zero()) && Ops[0]->getType() == GEPTy)
4353 if (!IsScalableVec && Ty->
isSized()) {
4358 if (TyAllocSize == 0 && Ops[0]->
getType() == GEPTy)
4365 auto CanSimplify = [GEPTy, &
P, V = Ops[0]]() ->
bool {
4366 return P->getType() == GEPTy &&
4370 if (TyAllocSize == 1 &&
4381 TyAllocSize == 1ULL <<
C && CanSimplify())
4396 all_of(Ops.slice(1).drop_back(1),
4397 [](
Value *Idx) { return match(Idx, m_Zero()); })) {
4401 APInt BasePtrOffset(IdxWidth, 0);
4402 Value *StrippedBasePtr =
4411 if (
match(Ops.back(),
4418 if (
match(Ops.back(),
4428 if (!
all_of(Ops, [](
Value *V) {
return isa<Constant>(V); }))
4446 if (
Constant *CAgg = dyn_cast<Constant>(Agg))
4447 if (
Constant *CVal = dyn_cast<Constant>(Val))
4456 if (EV->getAggregateOperand()->getType() == Agg->
getType() &&
4457 EV->getIndices() == Idxs) {
4460 return EV->getAggregateOperand();
4463 if (Agg == EV->getAggregateOperand())
4479 auto *VecC = dyn_cast<Constant>(Vec);
4480 auto *ValC = dyn_cast<Constant>(Val);
4481 auto *IdxC = dyn_cast<Constant>(Idx);
4482 if (VecC && ValC && IdxC)
4486 if (
auto *CI = dyn_cast<ConstantInt>(Idx)) {
4487 if (isa<FixedVectorType>(Vec->
getType()) &&
4488 CI->uge(cast<FixedVectorType>(Vec->
getType())->getNumElements()))
4498 if (isa<PoisonValue>(Val) ||
4515 if (
auto *CAgg = dyn_cast<Constant>(Agg))
4519 unsigned NumIdxs = Idxs.
size();
4520 for (
auto *IVI = dyn_cast<InsertValueInst>(Agg); IVI !=
nullptr;
4521 IVI = dyn_cast<InsertValueInst>(IVI->getAggregateOperand())) {
4523 unsigned NumInsertValueIdxs = InsertValueIdxs.
size();
4524 unsigned NumCommonIdxs =
std::min(NumInsertValueIdxs, NumIdxs);
4525 if (InsertValueIdxs.
slice(0, NumCommonIdxs) ==
4526 Idxs.
slice(0, NumCommonIdxs)) {
4527 if (NumIdxs == NumInsertValueIdxs)
4528 return IVI->getInsertedValueOperand();