48#define DEBUG_TYPE "correlated-value-propagation"
52 cl::desc(
"Enables canonicalization of signed relational predicates to "
53 "unsigned (e.g. sgt => ugt)"));
56STATISTIC(NumPhiCommon,
"Number of phis deleted via common incoming value");
57STATISTIC(NumSelects,
"Number of selects propagated");
58STATISTIC(NumMemAccess,
"Number of memory access targets propagated");
59STATISTIC(NumCmps,
"Number of comparisons propagated");
60STATISTIC(NumReturns,
"Number of return values propagated");
61STATISTIC(NumDeadCases,
"Number of switch cases removed");
63 "Number of sdivs/srems whose width was decreased");
64STATISTIC(NumSDivs,
"Number of sdiv converted to udiv");
66 "Number of udivs/urems whose width was decreased");
67STATISTIC(NumAShrsConverted,
"Number of ashr converted to lshr");
68STATISTIC(NumAShrsRemoved,
"Number of ashr removed");
69STATISTIC(NumSRems,
"Number of srem converted to urem");
70STATISTIC(NumSExt,
"Number of sext converted to zext");
71STATISTIC(NumSICmps,
"Number of signed icmp preds simplified to unsigned");
74STATISTIC(NumNSW,
"Number of no-signed-wrap deductions");
75STATISTIC(NumNUW,
"Number of no-unsigned-wrap deductions");
76STATISTIC(NumAddNW,
"Number of no-wrap deductions for add");
77STATISTIC(NumAddNSW,
"Number of no-signed-wrap deductions for add");
78STATISTIC(NumAddNUW,
"Number of no-unsigned-wrap deductions for add");
79STATISTIC(NumSubNW,
"Number of no-wrap deductions for sub");
80STATISTIC(NumSubNSW,
"Number of no-signed-wrap deductions for sub");
81STATISTIC(NumSubNUW,
"Number of no-unsigned-wrap deductions for sub");
82STATISTIC(NumMulNW,
"Number of no-wrap deductions for mul");
83STATISTIC(NumMulNSW,
"Number of no-signed-wrap deductions for mul");
84STATISTIC(NumMulNUW,
"Number of no-unsigned-wrap deductions for mul");
85STATISTIC(NumShlNW,
"Number of no-wrap deductions for shl");
86STATISTIC(NumShlNSW,
"Number of no-signed-wrap deductions for shl");
87STATISTIC(NumShlNUW,
"Number of no-unsigned-wrap deductions for shl");
88STATISTIC(NumAbs,
"Number of llvm.abs intrinsics removed");
89STATISTIC(NumOverflows,
"Number of overflow checks removed");
91 "Number of saturating arithmetics converted to normal arithmetics");
92STATISTIC(NumNonNull,
"Number of function pointer arguments marked non-null");
93STATISTIC(NumMinMax,
"Number of llvm.[us]{min,max} intrinsics removed");
95 "Number of bound udiv's/urem's expanded");
101 bool Changed =
false;
103 auto *
I = cast<Instruction>(U.getUser());
105 if (
auto *PN = dyn_cast<PHINode>(
I))
111 auto *CI = dyn_cast_or_null<ConstantInt>(
C);
141 Value *CommonValue =
nullptr;
142 for (
unsigned i = 0, e =
P->getNumIncomingValues(); i != e; ++i) {
143 Value *Incoming =
P->getIncomingValue(i);
144 if (
auto *IncomingConstant = dyn_cast<Constant>(Incoming)) {
145 IncomingConstants.
push_back(std::make_pair(IncomingConstant, i));
146 }
else if (!CommonValue) {
148 CommonValue = Incoming;
149 }
else if (Incoming != CommonValue) {
155 if (!CommonValue || IncomingConstants.
empty())
160 if (
auto *CommonInst = dyn_cast<Instruction>(CommonValue))
167 for (
auto &IncomingConstant : IncomingConstants) {
169 BasicBlock *IncomingBB =
P->getIncomingBlock(IncomingConstant.second);
182 P->replaceAllUsesWith(CommonValue);
183 P->eraseFromParent();
198 auto *SI = dyn_cast<SelectInst>(Incoming);
204 Value *Condition = SI->getCondition();
208 return SI->getTrueValue();
209 if (
C->isZeroValue())
210 return SI->getFalseValue();
220 if (
auto *
C = dyn_cast<Constant>(SI->getFalseValue()))
223 return SI->getTrueValue();
227 if (
auto *
C = dyn_cast<Constant>(SI->getTrueValue()))
230 return SI->getFalseValue();
237 bool Changed =
false;
240 for (
unsigned i = 0, e =
P->getNumIncomingValues(); i < e; ++i) {
241 Value *Incoming =
P->getIncomingValue(i);
242 if (isa<Constant>(Incoming))
continue;
246 P->setIncomingValue(i, V);
252 P->replaceAllUsesWith(V);
253 P->eraseFromParent();
267 Value *Pointer =
nullptr;
269 Pointer = L->getPointerOperand();
271 Pointer = cast<StoreInst>(
I)->getPointerOperand();
273 if (isa<Constant>(Pointer))
return false;
276 if (!
C)
return false;
279 I->replaceUsesOfWith(Pointer,
C);
288 if (Cmp->getType()->isVectorTy() ||
289 !Cmp->getOperand(0)->getType()->isIntegerTy())
292 if (!Cmp->isSigned())
300 if (UnsignedPred == ICmpInst::Predicate::BAD_ICMP_PREDICATE)
304 Cmp->setPredicate(UnsignedPred);
314 Value *Op0 = Cmp->getOperand(0);
315 Value *Op1 = Cmp->getOperand(1);
325 Cmp->replaceAllUsesWith(TorF);
326 Cmp->eraseFromParent();
334 if (
auto *ICmp = dyn_cast<ICmpInst>(Cmp))
355 bool Changed =
false;
358 SuccessorsCount[Succ]++;
364 for (
auto CI = SI->case_begin(), CE = SI->case_end(); CI != CE;) {
374 CI = SI.removeCase(CI);
379 Cond = SI->getCondition();
383 if (--SuccessorsCount[Succ] == 0)
391 SI->setCondition(Case);
392 NumDeadCases += SI->getNumCases();
420 bool NewNSW,
bool NewNUW) {
423 case Instruction::Add:
428 case Instruction::Sub:
433 case Instruction::Mul:
438 case Instruction::Shl:
447 auto *Inst = dyn_cast<Instruction>(V);
454 Inst->setHasNoSignedWrap();
462 Inst->setHasNoUnsignedWrap();
473 bool IsIntMinPoison = cast<ConstantInt>(II->
getArgOperand(1))->isOne();
475 Type *Ty =
X->getType();
481 Result = LVI->
getPredicateAt(CmpInst::Predicate::ICMP_ULE,
X, IntMin, II,
491 Constant *Zero = ConstantInt::getNullValue(Ty);
492 Result = LVI->
getPredicateAt(CmpInst::Predicate::ICMP_SLE,
X, Zero, II,
498 bool Changed =
false;
499 if (!IsIntMinPoison) {
501 Result = LVI->
getPredicateAt(CmpInst::Predicate::ICMP_NE,
X, IntMin, II,
521 if (
auto *BO = dyn_cast<BinaryOperator>(NegX))
562 if (
auto *BO = dyn_cast<BinaryOperator>(NewOp))
570 bool NSW = SI->isSigned();
571 bool NUW = !SI->isSigned();
573 Opcode, SI->getLHS(), SI->getRHS(), SI->getName(), SI);
577 SI->replaceAllUsesWith(BinOp);
578 SI->eraseFromParent();
582 if (
auto *BO = dyn_cast<BinaryOperator>(BinOp))
595 if (
auto *MM = dyn_cast<MinMaxIntrinsic>(&CB)) {
599 if (
auto *WO = dyn_cast<WithOverflowInst>(&CB)) {
600 if (WO->getLHS()->getType()->isIntegerTy() &&
willNotOverflow(WO, LVI)) {
605 if (
auto *SI = dyn_cast<SaturatingInst>(&CB)) {
611 bool Changed =
false;
621 for (
const Use &ConstU : DeoptBundle->Inputs) {
622 Use &U =
const_cast<Use&
>(ConstU);
624 if (V->getType()->isVectorTy())
continue;
625 if (isa<Constant>(V))
continue;
651 assert(ArgNo == CB.
arg_size() &&
"Call arguments not processed correctly.");
656 NumNonNull += ArgNos.
size();
680 assert(Instr->getOpcode() == Instruction::SDiv ||
681 Instr->getOpcode() == Instruction::SRem);
682 assert(!Instr->getType()->isVectorTy());
686 unsigned OrigWidth = Instr->getType()->getIntegerBitWidth();
690 unsigned MinSignedBits =
700 unsigned NewWidth = std::max<unsigned>(
PowerOf2Ceil(MinSignedBits), 8);
704 if (NewWidth >= OrigWidth)
707 ++NumSDivSRemsNarrowed;
710 auto *
LHS =
B.CreateTruncOrBitCast(Instr->getOperand(0), TruncTy,
711 Instr->getName() +
".lhs.trunc");
712 auto *
RHS =
B.CreateTruncOrBitCast(Instr->getOperand(1), TruncTy,
713 Instr->getName() +
".rhs.trunc");
714 auto *BO =
B.CreateBinOp(Instr->getOpcode(),
LHS,
RHS, Instr->getName());
715 auto *Sext =
B.CreateSExt(BO, Instr->getType(), Instr->getName() +
".sext");
716 if (
auto *BinOp = dyn_cast<BinaryOperator>(BO))
717 if (BinOp->getOpcode() == Instruction::SDiv)
718 BinOp->setIsExact(Instr->isExact());
720 Instr->replaceAllUsesWith(Sext);
721 Instr->eraseFromParent();
727 Type *Ty = Instr->getType();
728 assert(Instr->getOpcode() == Instruction::UDiv ||
729 Instr->getOpcode() == Instruction::URem);
731 bool IsRem = Instr->getOpcode() == Instruction::URem;
733 Value *
X = Instr->getOperand(0);
734 Value *
Y = Instr->getOperand(1);
738 if (XCR.
icmp(ICmpInst::ICMP_ULT, YCR)) {
740 Instr->eraseFromParent();
741 ++NumUDivURemsNarrowedExpanded;
769 if (!XCR.
icmp(ICmpInst::ICMP_ULT,
776 if (XCR.
icmp(ICmpInst::ICMP_UGE, YCR)) {
779 ExpandedOp =
B.CreateNUWSub(
X,
Y);
787 FrozenX =
B.CreateFreeze(
X,
X->getName() +
".frozen");
788 auto *AdjX =
B.CreateNUWSub(FrozenX,
Y, Instr->getName() +
".urem");
790 B.CreateICmp(ICmpInst::ICMP_ULT, FrozenX,
Y, Instr->getName() +
".cmp");
791 ExpandedOp =
B.CreateSelect(Cmp, FrozenX, AdjX);
794 B.CreateICmp(ICmpInst::ICMP_UGE,
X,
Y, Instr->getName() +
".cmp");
795 ExpandedOp =
B.CreateZExt(Cmp, Ty, Instr->getName() +
".udiv");
798 Instr->replaceAllUsesWith(ExpandedOp);
799 Instr->eraseFromParent();
800 ++NumUDivURemsNarrowedExpanded;
808 assert(Instr->getOpcode() == Instruction::UDiv ||
809 Instr->getOpcode() == Instruction::URem);
810 assert(!Instr->getType()->isVectorTy());
819 unsigned NewWidth = std::max<unsigned>(
PowerOf2Ceil(MaxActiveBits), 8);
823 if (NewWidth >= Instr->getType()->getIntegerBitWidth())
826 ++NumUDivURemsNarrowed;
829 auto *
LHS =
B.CreateTruncOrBitCast(Instr->getOperand(0), TruncTy,
830 Instr->getName() +
".lhs.trunc");
831 auto *
RHS =
B.CreateTruncOrBitCast(Instr->getOperand(1), TruncTy,
832 Instr->getName() +
".rhs.trunc");
833 auto *BO =
B.CreateBinOp(Instr->getOpcode(),
LHS,
RHS, Instr->getName());
834 auto *Zext =
B.CreateZExt(BO, Instr->getType(), Instr->getName() +
".zext");
835 if (
auto *BinOp = dyn_cast<BinaryOperator>(BO))
836 if (BinOp->getOpcode() == Instruction::UDiv)
837 BinOp->setIsExact(Instr->isExact());
839 Instr->replaceAllUsesWith(Zext);
840 Instr->eraseFromParent();
845 assert(Instr->getOpcode() == Instruction::UDiv ||
846 Instr->getOpcode() == Instruction::URem);
847 if (Instr->getType()->isVectorTy())
882 for (Operand &
Op : Ops) {
892 BinaryOperator::CreateURem(Ops[0].V, Ops[1].V, SDI->
getName(), SDI);
935 for (Operand &
Op : Ops) {
945 BinaryOperator::CreateUDiv(Ops[0].V, Ops[1].V, SDI->
getName(), SDI);
947 UDiv->setIsExact(SDI->
isExact());
952 if (Ops[0].
D != Ops[1].
D)
965 assert(Instr->getOpcode() == Instruction::SDiv ||
966 Instr->getOpcode() == Instruction::SRem);
967 if (Instr->getType()->isVectorTy())
972 if (Instr->getOpcode() == Instruction::SDiv)
976 if (Instr->getOpcode() == Instruction::SRem) {
993 if (NegOneOrZero.
contains(LRange)) {
1004 ++NumAShrsConverted;
1009 BO->setIsExact(SDI->
isExact());
1027 ZExt->takeName(SDI);
1053 bool Changed =
false;
1054 bool NewNUW =
false, NewNSW =
false;
1057 Opcode, RRange, OBO::NoUnsignedWrap);
1058 NewNUW = NUWRange.
contains(LRange);
1063 Opcode, RRange, OBO::NoSignedWrap);
1064 NewNSW = NSWRange.
contains(LRange);
1081 if (!
RHS || !
RHS->getValue().isMask())
1104 auto *
C = dyn_cast<CmpInst>(V);
1105 if (!
C)
return nullptr;
1107 Value *Op0 =
C->getOperand(0);
1108 Constant *Op1 = dyn_cast<Constant>(
C->getOperand(1));
1109 if (!Op1)
return nullptr;
1112 C->getPredicate(), Op0, Op1, At,
false);
1123 bool FnChanged =
false;
1130 bool BBChanged =
false;
1132 switch (II.getOpcode()) {
1133 case Instruction::Select:
1136 case Instruction::PHI:
1137 BBChanged |=
processPHI(cast<PHINode>(&II), LVI, DT, SQ);
1139 case Instruction::ICmp:
1140 case Instruction::FCmp:
1141 BBChanged |=
processCmp(cast<CmpInst>(&II), LVI);
1143 case Instruction::Load:
1144 case Instruction::Store:
1147 case Instruction::Call:
1148 case Instruction::Invoke:
1151 case Instruction::SRem:
1152 case Instruction::SDiv:
1155 case Instruction::UDiv:
1156 case Instruction::URem:
1159 case Instruction::AShr:
1160 BBChanged |=
processAShr(cast<BinaryOperator>(&II), LVI);
1162 case Instruction::SExt:
1163 BBChanged |=
processSExt(cast<SExtInst>(&II), LVI);
1165 case Instruction::Add:
1166 case Instruction::Sub:
1167 case Instruction::Mul:
1168 case Instruction::Shl:
1169 BBChanged |=
processBinOp(cast<BinaryOperator>(&II), LVI);
1171 case Instruction::And:
1172 BBChanged |=
processAnd(cast<BinaryOperator>(&II), LVI);
1178 switch (Term->getOpcode()) {
1179 case Instruction::Switch:
1180 BBChanged |=
processSwitch(cast<SwitchInst>(Term), LVI, DT);
1182 case Instruction::Ret: {
1183 auto *RI = cast<ReturnInst>(Term);
1187 auto *RetVal = RI->getReturnValue();
1189 if (isa<Constant>(RetVal))
break;
1192 RI->replaceUsesOfWith(RetVal,
C);
1198 FnChanged |= BBChanged;
This file contains the simple types necessary to represent the attributes associated with functions a...
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static bool runImpl(Function &F, const TargetLowering &TLI)
This is the interface for a simple mod/ref and alias analysis over globals.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
This header defines various interfaces for pass management in LLVM.
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
APInt sext(unsigned width) const
Sign extend to a new width.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
LLVM Basic Block Representation.
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
This class represents an intrinsic that is based on a binary operation.
unsigned getNoWrapKind() const
Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
bool isSigned() const
Whether the intrinsic is signed or unsigned.
Instruction::BinaryOps getBinaryOp() const
Returns the binary operation underlying the intrinsic.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
static BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
BinaryOps getOpcode() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
std::optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
Value * getArgOperand(unsigned i) const
void setArgOperand(unsigned i, Value *v)
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
unsigned arg_size() const
AttributeList getAttributes() const
Return the parameter attributes for this call.
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
This class is the base class for the comparison instructions.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_ULT
unsigned less than
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
This is the shared class of boolean and integer constants.
static ConstantInt * getTrue(LLVMContext &Context)
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static ConstantInt * getFalse(LLVMContext &Context)
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
This class represents a range of values.
unsigned getActiveBits() const
Compute the maximal number of active bits needed to represent every value in this range.
ConstantRange umul_sat(const ConstantRange &Other) const
Perform an unsigned saturating multiplication of two constant ranges.
static CmpInst::Predicate getEquivalentPredWithFlippedSignedness(CmpInst::Predicate Pred, const ConstantRange &CR1, const ConstantRange &CR2)
If the comparison between constant ranges this and Other is insensitive to the signedness of the comp...
bool isAllNegative() const
Return true if all values in this range are negative.
bool icmp(CmpInst::Predicate Pred, const ConstantRange &Other) const
Does the predicate Pred hold between ranges this and Other? NOTE: false does not mean that inverse pr...
ConstantRange abs(bool IntMinIsPoison=false) const
Calculate absolute value range.
bool isAllNonNegative() const
Return true if all values in this range are non-negative.
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
APInt getUnsignedMax() const
Return the largest unsigned value contained in the ConstantRange.
static ConstantRange makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, const ConstantRange &Other, unsigned NoWrapKind)
Produce the largest range containing all X such that "X BinOp Y" is guaranteed not to wrap (overflow)...
unsigned getMinSignedBits() const
Compute the maximal number of bits needed to represent every value in this signed range.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
This is an important base class in LLVM.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
This class represents an Operation in the Expression.
void applyUpdatesPermissive(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
Analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
This instruction compares its operands according to the predicate given to the constructor.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
bool hasNoUnsignedWrap() const LLVM_READONLY
Determine whether the no unsigned wrap flag is set.
bool hasNoSignedWrap() const LLVM_READONLY
Determine whether the no signed wrap flag is set.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
bool isExact() const LLVM_READONLY
Determine whether the exact flag is set.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
Analysis to compute lazy value information.
This pass computes, caches, and vends lazy value constraint information.
ConstantRange getConstantRangeAtUse(const Use &U, bool UndefAllowed=true)
Return the ConstantRange constraint that is known to hold for the value at a specific use-site.
Tristate
This is used to return true/false/dunno results.
Constant * getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB, Instruction *CxtI=nullptr)
Determine whether the specified value is known to be a constant on the specified edge.
Tristate getPredicateOnEdge(unsigned Pred, Value *V, Constant *C, BasicBlock *FromBB, BasicBlock *ToBB, Instruction *CxtI=nullptr)
Determine whether the specified value comparison with a constant is known to be true or false on the ...
Tristate getPredicateAt(unsigned Pred, Value *V, Constant *C, Instruction *CxtI, bool UseBlockValue)
Determine whether the specified value comparison with a constant is known to be true or false at the ...
Constant * getConstant(Value *V, Instruction *CxtI)
Determine whether the specified value is known to be a constant at the specified instruction.
ConstantRange getConstantRange(Value *V, Instruction *CxtI, bool UndefAllowed=true)
Return the ConstantRange constraint that is known to hold for the specified value at the specified in...
An instruction for reading from memory.
This class represents min/max intrinsics.
static ICmpInst::Predicate getPredicate(Intrinsic::ID ID)
Returns the comparison predicate underlying the intrinsic.
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void abandon()
Mark an analysis as abandoned.
void preserve()
Mark an analysis as preserved.
This class represents a sign extension of integer types.
Represents a saturating add/sub intrinsic.
This class represents the LLVM 'select' instruction.
const Value * getFalseValue() const
const Value * getCondition() const
const Value * getTrueValue() const
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Class to represent struct types.
A wrapper class to simplify modification of SwitchInst cases along with their prof branch_weights met...
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getIntegerBitWidth() const
bool isVectorTy() const
True if this is an instance of VectorType.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
A Use represents the edge between a Value definition and its users.
const Use & getOperandUse(unsigned i) const
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
iterator_range< use_iterator > uses()
StringRef getName() const
Return a constant reference to the value's name.
void takeName(Value *V)
Transfer the name from V to this value.
Represents an op.with.overflow intrinsic.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr, DomTreeUpdater *DTU=nullptr)
If a terminator instruction is predicated on a constant value, convert it into an unconditional branc...
auto successors(const MachineBasicBlock *BB)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q)
See if we can compute a simplified version of this instruction.
bool isGuaranteedNotToBeUndefOrPoison(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Return true if this function can prove that V does not have undef bits and is never poison.
iterator_range< df_iterator< T > > depth_first(const T &G)
bool isGuaranteedNotToBePoison(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
const SimplifyQuery getBestSimplifyQuery(Pass &, Function &)