28#define DEBUG_TYPE "instcombine"
32 cl::desc(
"Maximum number phis to handle in intptr/ptrint folding"));
35 "Number of phi-of-insertvalue turned into insertvalue-of-phis");
37 "Number of phi-of-extractvalue turned into extractvalue-of-phi");
38STATISTIC(NumPHICSEs,
"Number of PHI's that got CSE'd");
64 while (!Stack.empty()) {
65 PHINode *Phi = Stack.pop_back_val();
66 for (
User *
Use : Phi->users()) {
68 if (!Visited.
insert(PhiUse).second)
71 if (Visited.
size() >= 16)
73 Stack.push_back(PhiUse);
148 Value *Ptr =
nullptr;
150 Ptr = LoadI->getPointerOperand();
152 Ptr =
SI->getPointerOperand();
154 Ptr = GI->getPointerOperand();
157 if (Ptr && Ptr == IIP)
163 if (!HasPointerUse(IntToPtr))
166 if (
DL.getPointerSizeInBits(IntToPtr->getAddressSpace()) !=
167 DL.getTypeSizeInBits(IntToPtr->getOperand(0)->getType()))
173 Value *Arg = std::get<1>(Incoming);
181 if (PI->getOperand(0)->getType() == IntToPtr->getType()) {
188 Value *ArgIntToPtr =
nullptr;
215 if (!LoadI->hasOneUse())
227 "Not enough available ptr typed incoming values");
228 PHINode *MatchingPtrPHI =
nullptr;
229 unsigned NumPhis = 0;
230 for (
PHINode &PtrPHI : BB->phis()) {
234 if (&PtrPHI == &PN || PtrPHI.
getType() != IntToPtr->getType())
237 [&](
const auto &BlockAndValue) {
238 BasicBlock *BB = std::get<0>(BlockAndValue);
239 Value *V = std::get<1>(BlockAndValue);
240 return PtrPHI.getIncomingValueForBlock(BB) != V;
243 MatchingPtrPHI = &PtrPHI;
247 if (MatchingPtrPHI) {
249 "Phi's Type does not match with IntToPtr");
269 if (V->getType() == IntToPtr->getType())
274 if (Inst->isTerminator())
276 auto *BB = Inst->getParent();
288 for (
auto Incoming :
zip(PN.
blocks(), AvailablePtrVals)) {
289 auto *IncomingBB = std::get<0>(Incoming);
290 auto *IncomingVal = std::get<1>(Incoming);
292 if (IncomingVal->getType() == IntToPtr->getType()) {
300 IncomingVal->getType()->isPointerTy() ||
302 "Can not replace LoadInst with multiple uses");
315 IncomingVal->getName() +
".ptr");
322 assert(InsertPos != BB->
end() &&
"should have checked above");
325 auto *InsertBB = &IncomingBB->getParent()->getEntryBlock();
350 bool OperandWithRoundTripCast =
false;
355 OperandWithRoundTripCast =
true;
358 if (!OperandWithRoundTripCast)
373 if (!
I || !
I->hasOneUser() ||
I->getIndices() != FirstIVI->getIndices())
378 std::array<PHINode *, 2> NewOperands;
379 for (
int OpIdx : {0, 1}) {
380 auto *&NewOperand = NewOperands[
OpIdx];
385 FirstIVI->getOperand(
OpIdx)->getName() +
".pn");
388 NewOperand->addIncoming(
390 std::get<0>(Incoming));
396 FirstIVI->getIndices(), PN.
getName());
399 ++NumPHIsOfInsertValues;
413 if (!
I || !
I->hasOneUser() ||
I->getIndices() != FirstEVI->getIndices() ||
414 I->getAggregateOperand()->getType() !=
415 FirstEVI->getAggregateOperand()->getType())
423 FirstEVI->getAggregateOperand()->getName() +
".pn");
426 NewAggregateOperand->addIncoming(
428 std::get<0>(Incoming));
433 FirstEVI->getIndices(), PN.
getName());
436 ++NumPHIsOfExtractValues;
455 if (!
I ||
I->getOpcode() !=
Opc || !
I->hasOneUser() ||
458 I->getOperand(0)->getType() != LHSType ||
459 I->getOperand(1)->getType() != RHSType)
464 if (CI->getPredicate() !=
cast<CmpInst>(FirstInst)->getPredicate())
468 if (
I->getOperand(0) != LHSVal) LHSVal =
nullptr;
469 if (
I->getOperand(1) != RHSVal) RHSVal =
nullptr;
476 if (!LHSVal && !RHSVal)
483 PHINode *NewLHS =
nullptr, *NewRHS =
nullptr;
501 if (NewLHS || NewRHS) {
504 Value *InVal = std::get<1>(Incoming);
512 NewRHS->addIncoming(NewInRHS, InBB);
544 bool AllBasePointersAreAllocas =
true;
549 bool NeededPhi =
false;
557 if (!
GEP || !
GEP->hasOneUser() ||
562 NW &=
GEP->getNoWrapFlags();
565 if (AllBasePointersAreAllocas &&
567 !
GEP->hasAllConstantIndices()))
568 AllBasePointersAreAllocas =
false;
585 GEP->getOperand(
Op)->getType())
595 FixedOperands[
Op] =
nullptr;
606 if (AllBasePointersAreAllocas)
613 bool HasAnyPHIs =
false;
614 for (
unsigned I = 0, E = FixedOperands.
size();
I != E; ++
I) {
615 if (FixedOperands[
I])
623 OperandPhis[
I] = NewPN;
624 FixedOperands[
I] = NewPN;
632 Value *InVal = std::get<1>(Incoming);
635 for (
unsigned Op = 0, E = OperandPhis.
size();
Op != E; ++
Op)
644 ArrayRef(FixedOperands).slice(1), NW);
659 for (++BBI; BBI !=
E; ++BBI)
660 if (BBI->mayWriteToMemory()) {
664 if (CB->onlyAccessesInaccessibleMemory())
672 bool IsAddressTaken =
false;
677 if (
SI->getOperand(1) == AI)
continue;
679 IsAddressTaken =
true;
683 if (!IsAddressTaken && AI->isStaticAlloca())
694 if (AI->isStaticAlloca() &&
GEP->hasAllConstantIndices())
724 Value *InVal = std::get<1>(Incoming);
741 LoadAlignment = std::min(LoadAlignment, LI->
getAlign());
753 false, LoadAlignment);
759 Value *V = std::get<1>(Incoming);
763 if (NewInVal != InVal)
787 if (
Instruction *TI = Phi.getParent()->getTerminator())
794 unsigned NumIncomingValues = Phi.getNumIncomingValues();
795 if (NumIncomingValues < 3)
799 Type *NarrowType =
nullptr;
800 for (
Value *V : Phi.incoming_values()) {
802 NarrowType = Zext->getSrcTy();
812 unsigned NumZexts = 0;
813 unsigned NumConsts = 0;
814 for (
Value *V : Phi.incoming_values()) {
817 if (Zext->getSrcTy() != NarrowType || !Zext->hasOneUser())
819 NewIncoming.
push_back(Zext->getOperand(0));
840 if (NumConsts == 0 || NumZexts < 2)
847 Phi.getName() +
".shrunk");
848 for (
unsigned I = 0;
I != NumIncomingValues; ++
I)
849 NewPhi->
addIncoming(NewIncoming[
I], Phi.getIncomingBlock(
I));
888 Type *CastSrcTy =
nullptr;
896 if (!shouldChangeType(PN.
getType(), CastSrcTy))
912 if (!
I || !
I->hasOneUser() || !
I->isSameOperationAs(FirstInst))
915 if (
I->getOperand(0)->getType() != CastSrcTy)
917 }
else if (
I->getOperand(1) != ConstantOp) {
934 Value *V = std::get<1>(Incoming);
936 if (NewInVal != InVal)
965 BinOp->andIRFlags(V);
984 if (!ValueEqualPHIs.
insert(PN).second)
988 if (ValueEqualPHIs.
size() >= 16)
1000 }
else if (
Op != NonPhiInVal)
1013 if (!ConstVA->isZero())
1019struct PHIUsageRecord {
1024 PHIUsageRecord(
unsigned Pn,
unsigned Sh, Instruction *User)
1025 : PHIId(Pn), Shift(Sh), Inst(
User) {}
1028 if (PHIId <
RHS.PHIId)
return true;
1029 if (PHIId >
RHS.PHIId)
return false;
1030 if (Shift <
RHS.Shift)
return true;
1031 if (Shift >
RHS.Shift)
return false;
1037struct LoweredPHIRecord {
1042 LoweredPHIRecord(PHINode *Phi,
unsigned Sh,
Type *Ty)
1043 : PN(
Phi), Shift(Sh), Width(Ty->getPrimitiveSizeInBits()) {}
1046 LoweredPHIRecord(PHINode *Phi,
unsigned Sh) : PN(
Phi), Shift(Sh), Width(0) {}
1052 return LoweredPHIRecord(
nullptr, 0);
1055 return LoweredPHIRecord(
nullptr, 1);
1062 const LoweredPHIRecord &RHS) {
1063 return LHS.PN == RHS.PN && LHS.Shift == RHS.Shift && LHS.Width == RHS.Width;
1088 PHIsInspected.
insert(&FirstPhi);
1090 for (
unsigned PHIId = 0; PHIId != PHIsToSlice.
size(); ++PHIId) {
1091 PHINode *PN = PHIsToSlice[PHIId];
1098 if (PHIsInspected.
insert(UserPN).second)
1105 PHIUsers.
push_back(PHIUsageRecord(PHIId, 0, UserI));
1110 if (UserI->
getOpcode() != Instruction::LShr ||
1125 for (
const auto &PN : PHIsToSlice) {
1130 for (
auto Incoming :
zip(PN->blocks(), PN->incoming_values())) {
1132 Value *V = std::get<1>(Incoming);
1136 if (
II->getParent() != BB)
1148 for (
auto *Pred : PN->blocks())
1149 if (!Pred->hasInsertionPt())
1154 if (PHIUsers.
empty())
1162 for (
unsigned I = 1;
I != PHIsToSlice.
size(); ++
I)
dbgs()
1163 <<
"AND USER PHI #" <<
I <<
": " << *PHIsToSlice[
I] <<
'\n');
1173 for (
unsigned UserI = 0, UserE = PHIUsers.
size(); UserI != UserE; ++UserI) {
1174 unsigned PHIId = PHIUsers[UserI].PHIId;
1175 PHINode *PN = PHIsToSlice[PHIId];
1176 unsigned Offset = PHIUsers[UserI].Shift;
1177 Type *Ty = PHIUsers[UserI].Inst->getType();
1183 if ((EltPHI = ExtractedVals[LoweredPHIRecord(PN,
Offset, Ty)]) ==
nullptr) {
1190 "Truncate didn't shrink phi?");
1194 Value *InVal = std::get<1>(Incoming);
1195 Value *&PredVal = PredValues[Pred];
1212 if (
Value *Res = ExtractedVals[LoweredPHIRecord(PN,
Offset, Ty)]) {
1219 Builder.SetInsertPoint(Pred->getTerminator());
1223 Res, ConstantInt::get(InVal->
getType(),
Offset),
"extract");
1224 Res =
Builder.CreateTrunc(Res, Ty,
"extract.t");
1233 if (PHIsInspected.
count(OldInVal)) {
1235 find(PHIsToSlice, OldInVal) - PHIsToSlice.
begin();
1244 << *EltPHI <<
'\n');
1245 ExtractedVals[LoweredPHIRecord(PN,
Offset, Ty)] = EltPHI;
1290 SuccForValue[
C] = Succ;
1294 Cond = BI->getCondition();
1298 Cond =
SI->getCondition();
1299 ++SuccCount[
SI->getDefaultDest()];
1300 for (
auto Case :
SI->cases())
1301 AddSucc(Case.getCaseValue(), Case.getCaseSuccessor());
1311 std::optional<bool> Invert;
1320 return It != SuccForValue.
end() && SuccCount[It->second] == 1 &&
1327 if (IsCorrectInput(
Input))
1328 NeedsInvert =
false;
1335 if (Invert && *Invert != NeedsInvert)
1338 Invert = NeedsInvert;
1348 if (InsertPt != BB->
end()) {
1368 auto MatchOuterIV = [&](
Value *V1,
Value *V2) {
1383 Value *Iv2Start, *Iv2Step;
1392 if (Iv2Start != Identity)
1398 return Builder.CreateGEP(
GEP->getSourceElementType(), Start, Iv2,
"",
1402 assert(BO->isCommutative() &&
"Must be commutative");
1403 Value *Res = Builder.CreateBinOp(BO->getOpcode(), Iv2, Start);
1424 if (Inst0 && Inst1 && Inst0->getOpcode() == Inst1->getOpcode() &&
1425 Inst0->hasOneUser())
1438 if (IV0 != IV0Stripped &&
1440 return !CheckedIVs.insert(IV).second ||
1441 IV0Stripped == IV->stripPointerCasts();
1485 auto *CmpInst = dyn_cast<ICmpInst>(U);
1489 if (U->hasOneUse() && match(U, m_c_Or(m_Specific(&PN), m_Value()))) {
1490 DropPoisonFlags.push_back(cast<Instruction>(U));
1491 CmpInst = dyn_cast<ICmpInst>(U->user_back());
1501 if (AllUsesOfPhiEndsInCmp) {
1503 bool MadeChange =
false;
1510 if (NonZeroConst != VA) {
1514 I->dropPoisonGeneratingFlags();
1533 unsigned InValNo = 0, NumIncomingVals = PN.getNumIncomingValues();
1535 while (InValNo != NumIncomingVals &&
1539 Value *NonPhiInVal =
1540 InValNo != NumIncomingVals ? PN.getIncomingValue(InValNo) :
nullptr;
1545 for (++InValNo; InValNo != NumIncomingVals; ++InValNo) {
1546 Value *OpVal = PN.getIncomingValue(InValNo);
1554 if (InValNo == NumIncomingVals) {
1557 return replaceInstUsesWith(PN, NonPhiInVal);
1565 auto Res = PredOrder.try_emplace(PN.getParent());
1567 const auto &Preds = Res.first->second;
1568 for (
unsigned I = 0,
E = PN.getNumIncomingValues();
I !=
E; ++
I) {
1572 Value *VA = PN.getIncomingValue(
I);
1573 unsigned J = PN.getBasicBlockIndex(BBB);
1574 Value *VB = PN.getIncomingValue(J);
1575 PN.setIncomingBlock(
I, BBB);
1576 PN.setIncomingValue(
I, VB);
1577 PN.setIncomingBlock(J, BBA);
1578 PN.setIncomingValue(J, VA);
1593 if (&IdenticalPN == &PN)
1598 if (!PN.isIdenticalToWhenDefined(&IdenticalPN))
1602 return replaceInstUsesWith(PN, &IdenticalPN);
1609 if (PN.getType()->isIntegerTy() &&
1610 !
DL.isLegalInteger(PN.getType()->getPrimitiveSizeInBits()))
1611 if (
Instruction *Res = SliceUpIllegalIntegerPHI(PN))
1616 return replaceInstUsesWith(PN, V);
1619 return replaceInstUsesWith(PN, Res);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file provides internal interfaces used to implement the InstCombine.
static ConstantInt * getAnyNonZeroConstInt(PHINode &PN)
Return an existing non-zero constant if this phi node has one, otherwise return constant 1.
static Value * foldDependentIVs(PHINode &PN, IRBuilderBase &Builder)
static bool isSafeAndProfitableToSinkLoad(LoadInst *L)
Return true if we know that it is safe to sink the load out of the block that defines it.
static Value * simplifyUsingControlFlow(InstCombiner &Self, PHINode &PN, const DominatorTree &DT)
static bool PHIsEqualValue(PHINode *PN, Value *&NonPhiInVal, SmallPtrSetImpl< PHINode * > &ValueEqualPHIs)
Return true if this phi node is always equal to NonPhiInVal.
static cl::opt< unsigned > MaxNumPhis("instcombine-max-num-phis", cl::init(512), cl::desc("Maximum number phis to handle in intptr/ptrint folding"))
This file provides the interface for the instcombine pass implementation.
MachineInstr unsigned OpIdx
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > & Cond
This file defines the SmallPtrSet class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static const uint32_t IV[8]
an instruction to allocate memory on the stack
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
BinaryOps getOpcode() const
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
This is the base class for all instructions that perform data casts.
static LLVM_ABI CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
static LLVM_ABI CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
static LLVM_ABI CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
This class is the base class for the comparison instructions.
static LLVM_ABI bool isEquality(Predicate pred)
Determine if this is an equals/not equals predicate.
static LLVM_ABI CmpInst * Create(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
Predicate getPredicate() const
Return the predicate for this instruction.
OtherOps getOpcode() const
Get the opcode casted to the right type.
static LLVM_ABI Constant * getNot(Constant *C)
static LLVM_ABI Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary opcode.
This is the shared class of boolean and integer constants.
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
This is an important base class in LLVM.
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
static DebugLoc getDropped()
iterator find(const_arg_type_t< KeyT > Val)
DomTreeNodeBase * getIDom() const
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
Represents flags for the getelementptr instruction/expression.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Type * getSourceElementType() const
LLVM_ABI GEPNoWrapFlags getNoWrapFlags() const
Get the nowrap flags for the GEP instruction.
Common base class shared among various IRBuilders.
Value * CreateNot(Value *V, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Instruction * foldPHIArgInsertValueInstructionIntoPHI(PHINode &PN)
If we have something like phi [insertvalue(a,b,0), insertvalue(c,d,0)], turn this into a phi[a,...
Instruction * foldPHIArgBinOpIntoPHI(PHINode &PN)
If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the adds all have a single user,...
Instruction * eraseInstFromFunction(Instruction &I) override
Combiner aware instruction erasure.
Instruction * visitPHINode(PHINode &PN)
Instruction * foldPHIArgOpIntoPHI(PHINode &PN)
Try to rotate an operation below a PHI node, using PHI nodes for its operands.
Instruction * foldPHIArgZextsIntoPHI(PHINode &PN)
TODO: This function could handle other cast types, but then it might require special-casing a cast fr...
Instruction * foldPHIArgLoadIntoPHI(PHINode &PN)
bool foldIntegerTypedPHI(PHINode &PN)
If an integer typed PHI has only one use which is an IntToPtr operation, replace the PHI with an exis...
bool foldDeadPhiWeb(PHINode &PN)
If the phi is within a phi web, which is formed by the def-use chain of phis and all the phis in the ...
Instruction * foldPHIArgIntToPtrToPHI(PHINode &PN)
Instruction * SliceUpIllegalIntegerPHI(PHINode &PN)
This is an integer PHI and we know that it has an illegal type: see if it is only used by trunc or tr...
Instruction * foldPHIArgGEPIntoPHI(PHINode &PN)
void PHIArgMergedDebugLoc(Instruction *Inst, PHINode &PN)
Helper function for FoldPHIArgXIntoPHI() to set debug location for the folded operation.
Instruction * foldPHIArgExtractValueInstructionIntoPHI(PHINode &PN)
If we have something like phi [extractvalue(a,0), extractvalue(b,0)], turn this into a phi[a,...
The core instruction combiner logic.
Instruction * InsertNewInstBefore(Instruction *New, BasicBlock::iterator Old)
Inserts an instruction New before instruction Old.
Instruction * replaceInstUsesWith(Instruction &I, Value *V)
A combiner-aware RAUW-like routine.
Instruction * replaceOperand(Instruction &I, unsigned OpNum, Value *V)
Replace operand of instruction and add old operand to the worklist.
const SimplifyQuery & getSimplifyQuery() const
LLVM_ABI void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction.
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM_ABI void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
LLVM_ABI void applyMergedLocation(DebugLoc LocA, DebugLoc LocB)
Merge 2 debug locations and apply it to the Instruction.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Align getAlign() const
Return the alignment of the access that is being performed.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
iterator_range< const_block_iterator > blocks() const
op_range incoming_values()
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI bool hasOneUser() const
Return true if there is exactly one user of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
LLVMContext & getContext() const
All values hold a context through their type.
iterator_range< user_iterator > users()
LLVM_ABI bool hasNUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
const ParentTy * getParent() const
self_iterator getIterator()
@ C
The default llvm calling convention, compatible with C.
bool match(Val *V, const Pattern &P)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
auto m_BinOp()
Match an arbitrary binary operation and ignore it.
auto m_GEP(const OperandTypes &...Ops)
Matches GetElementPtrInst.
AnyBinaryOp_match< LHS, RHS, true > m_c_BinOp(const LHS &L, const RHS &R)
Matches a BinaryOperator with LHS and RHS in either order.
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
initializer< Ty > init(const Ty &Val)
@ User
could "use" a pointer
NodeAddr< PhiNode * > Phi
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
bool operator<(int64_t V1, const APSInt &V2)
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
LLVM_ABI Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q)
See if we can compute a simplified version of this instruction.
LLVM_ABI bool matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO, Value *&Start, Value *&Step)
Attempt to match a simple first order recurrence cycle of the form: iv = phi Ty [Start,...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI Constant * getLosslessUnsignedTrunc(Constant *C, Type *DestTy, const DataLayout &DL, PreservedCastFlags *Flags=nullptr)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI bool isKnownNonZero(const Value *V, const SimplifyQuery &Q, unsigned Depth=0)
Return true if the given value is known to be non-zero when defined.
LLVM_ABI void combineMetadataForCSE(Instruction *K, const Instruction *J, bool DoesKMove)
Combine the metadata of two instructions so that K can replace J.
LLVM_ABI bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx)
Given an instruction, is it legal to set operand OpIdx to a non-constant value?
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static bool isEqual(const LoweredPHIRecord &LHS, const LoweredPHIRecord &RHS)
static unsigned getHashValue(const LoweredPHIRecord &Val)
static LoweredPHIRecord getEmptyKey()
static LoweredPHIRecord getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...