65 #define DEBUG_TYPE "early-cse" 67 STATISTIC(NumSimplify,
"Number of instructions simplified or DCE'd");
68 STATISTIC(NumCSE,
"Number of instructions CSE'd");
69 STATISTIC(NumCSECVP,
"Number of compare instructions CVP'd");
70 STATISTIC(NumCSELoad,
"Number of load instructions CSE'd");
71 STATISTIC(NumCSECall,
"Number of call instructions CSE'd");
72 STATISTIC(NumDSE,
"Number of trivial dead stores removed");
75 "Controls which instructions are removed");
98 if (
CallInst *CI = dyn_cast<CallInst>(Inst))
99 return CI->doesNotAccessMemory() && !CI->getType()->isVoidTy();
100 return isa<CastInst>(Inst) || isa<BinaryOperator>(Inst) ||
101 isa<GetElementPtrInst>(Inst) || isa<CmpInst>(Inst) ||
102 isa<SelectInst>(Inst) || isa<ExtractElementInst>(Inst) ||
103 isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
104 isa<ExtractValueInst>(Inst) || isa<InsertValueInst>(Inst);
121 static unsigned getHashValue(SimpleValue Val);
122 static bool isEqual(SimpleValue LHS, SimpleValue RHS);
131 Value *LHS = BinOp->getOperand(0);
132 Value *RHS = BinOp->getOperand(1);
133 if (BinOp->isCommutative() && BinOp->getOperand(0) > BinOp->getOperand(1))
139 if (
CmpInst *CI = dyn_cast<CmpInst>(Inst)) {
140 Value *LHS = CI->getOperand(0);
141 Value *RHS = CI->getOperand(1);
145 Pred = CI->getSwappedPredicate();
168 if (
CastInst *CI = dyn_cast<CastInst>(Inst))
169 return hash_combine(CI->getOpcode(), CI->getType(), CI->getOperand(0));
172 return hash_combine(EVI->getOpcode(), EVI->getOperand(0),
176 return hash_combine(IVI->getOpcode(), IVI->getOperand(0),
180 assert((isa<CallInst>(Inst) || isa<BinaryOperator>(Inst) ||
181 isa<GetElementPtrInst>(Inst) || isa<SelectInst>(Inst) ||
182 isa<ExtractElementInst>(Inst) || isa<InsertElementInst>(Inst) ||
183 isa<ShuffleVectorInst>(Inst)) &&
184 "Invalid/unknown instruction");
195 if (LHS.isSentinel() || RHS.isSentinel())
198 if (LHSI->
getOpcode() != RHSI->getOpcode())
205 if (!LHSBinOp->isCommutative())
208 assert(isa<BinaryOperator>(RHSI) &&
209 "same opcode, but different instruction type?");
214 LHSBinOp->getOperand(1) == RHSBinOp->
getOperand(0);
216 if (
CmpInst *LHSCmp = dyn_cast<CmpInst>(LHSI)) {
217 assert(isa<CmpInst>(RHSI) &&
218 "same opcode, but different instruction type?");
219 CmpInst *RHSCmp = cast<CmpInst>(RHSI);
222 LHSCmp->getOperand(1) == RHSCmp->
getOperand(0) &&
223 LHSCmp->getSwappedPredicate() == RHSCmp->
getPredicate();
239 return LHSA == RHSA && LHSB == RHSB;
240 return ((LHSA == RHSA && LHSB == RHSB) ||
241 (LHSA == RHSB && LHSB == RHSA));
293 static unsigned getHashValue(CallValue Val);
294 static bool isEqual(CallValue LHS, CallValue RHS);
309 if (LHS.isSentinel() || RHS.isSentinel())
335 std::unique_ptr<MemorySSAUpdater> MSSAUpdater;
350 ScopedHTType AvailableValues;
368 unsigned Generation = 0;
370 bool IsAtomic =
false;
372 LoadValue() =
default;
373 LoadValue(
Instruction *Inst,
unsigned Generation,
unsigned MatchingId,
375 : DefInst(Inst), Generation(Generation), MatchingId(MatchingId),
376 IsAtomic(IsAtomic) {}
379 using LoadMapAllocator =
386 LoadHTType AvailableLoads;
391 using InvariantMapAllocator =
394 using InvariantHTType =
396 InvariantMapAllocator>;
397 InvariantHTType AvailableInvariants;
405 CallHTType AvailableCalls;
408 unsigned CurrentGeneration = 0;
414 : TLI(TLI), TTI(TTI), DT(DT), AC(AC), SQ(DL, &TLI, &DT, &AC), MSSA(MSSA),
415 MSSAUpdater(llvm::make_unique<MemorySSAUpdater>(MSSA)) {}
425 NodeScope(ScopedHTType &AvailableValues, LoadHTType &AvailableLoads,
426 InvariantHTType &AvailableInvariants, CallHTType &AvailableCalls)
427 : Scope(AvailableValues), LoadScope(AvailableLoads),
428 InvariantScope(AvailableInvariants), CallScope(AvailableCalls) {}
429 NodeScope(
const NodeScope &) =
delete;
430 NodeScope &operator=(
const NodeScope &) =
delete;
433 ScopedHTType::ScopeTy Scope;
434 LoadHTType::ScopeTy LoadScope;
435 InvariantHTType::ScopeTy InvariantScope;
436 CallHTType::ScopeTy CallScope;
445 StackNode(ScopedHTType &AvailableValues, LoadHTType &AvailableLoads,
446 InvariantHTType &AvailableInvariants, CallHTType &AvailableCalls,
449 : CurrentGeneration(cg), ChildGeneration(cg), Node(n), ChildIter(child),
451 Scopes(AvailableValues, AvailableLoads, AvailableInvariants,
454 StackNode(
const StackNode &) =
delete;
455 StackNode &operator=(
const StackNode &) =
delete;
458 unsigned currentGeneration() {
return CurrentGeneration; }
459 unsigned childGeneration() {
return ChildGeneration; }
471 bool isProcessed() {
return Processed; }
472 void process() { Processed =
true; }
475 unsigned CurrentGeneration;
476 unsigned ChildGeneration;
481 bool Processed =
false;
486 class ParseMemoryInst {
492 IsTargetMemInst =
true;
496 if (IsTargetMemInst)
return Info.ReadMem;
497 return isa<LoadInst>(Inst);
501 if (IsTargetMemInst)
return Info.WriteMem;
502 return isa<StoreInst>(Inst);
511 bool isUnordered()
const {
513 return Info.isUnordered();
515 if (
LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
516 return LI->isUnordered();
517 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
518 return SI->isUnordered();
526 return Info.IsVolatile;
528 if (
LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
529 return LI->isVolatile();
530 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
531 return SI->isVolatile();
537 bool isInvariantLoad()
const {
538 if (
auto *LI = dyn_cast<LoadInst>(Inst))
543 bool isMatchingMemLoc(
const ParseMemoryInst &Inst)
const {
545 getMatchingId() == Inst.getMatchingId());
554 int getMatchingId()
const {
555 if (IsTargetMemInst)
return Info.MatchingId;
560 if (IsTargetMemInst)
return Info.PtrVal;
564 bool mayReadFromMemory()
const {
565 if (IsTargetMemInst)
return Info.ReadMem;
566 return Inst->mayReadFromMemory();
569 bool mayWriteToMemory()
const {
570 if (IsTargetMemInst)
return Info.WriteMem;
571 return Inst->mayWriteToMemory();
575 bool IsTargetMemInst =
false;
586 if (
auto *LI = dyn_cast<LoadInst>(Inst))
588 if (
auto *
SI = dyn_cast<StoreInst>(Inst))
589 return SI->getValueOperand();
590 assert(isa<IntrinsicInst>(Inst) &&
"Instruction not supported");
597 bool isOperatingOnInvariantMemAt(
Instruction *I,
unsigned GenAt);
599 bool isSameMemGeneration(
unsigned EarlierGeneration,
unsigned LaterGeneration,
619 for (
unsigned I = 0; I < WorkQueue.
size(); ++
I) {
622 for (
auto *U : WI->
users())
623 if (
MemoryPhi *MP = dyn_cast<MemoryPhi>(U))
626 MSSAUpdater->removeMemoryAccess(WI);
631 [=](
Use &
In) {
return In == FirstIn; }))
658 bool EarlyCSE::isSameMemGeneration(
unsigned EarlierGeneration,
659 unsigned LaterGeneration,
663 if (EarlierGeneration == LaterGeneration)
676 auto *EarlierMA = MSSA->getMemoryAccess(EarlierInst);
679 auto *LaterMA = MSSA->getMemoryAccess(LaterInst);
688 MSSA->getWalker()->getClobberingMemoryAccess(LaterInst);
689 return MSSA->dominates(LaterDef, EarlierMA);
692 bool EarlyCSE::isOperatingOnInvariantMemAt(
Instruction *I,
unsigned GenAt) {
695 if (
auto *LI = dyn_cast<LoadInst>(I))
705 if (!AvailableInvariants.count(MemLoc))
710 return AvailableInvariants.lookup(MemLoc) <= GenAt;
713 bool EarlyCSE::handleBranchCondition(
Instruction *CondInst,
724 return BOp->getOpcode() == Opcode;
730 unsigned PropagateOpcode =
731 (BI->
getSuccessor(0) == BB) ? Instruction::And : Instruction::Or;
733 bool MadeChanges =
false;
737 while (!WorkList.
empty()) {
740 AvailableValues.insert(Curr, TorF);
742 << Curr->
getName() <<
"' as " << *TorF <<
" in " 755 if (MatchBinOp(Curr, PropagateOpcode))
756 for (
auto &
Op : cast<BinaryOperator>(Curr)->operands())
758 if (SimpleValue::canHandle(OPI) && Visited.
insert(OPI).second)
766 bool Changed =
false;
788 if (CondInst && SimpleValue::canHandle(CondInst))
789 Changed |= handleBranchCondition(CondInst, BI, BB, Pred);
823 if (
match(Inst, m_Intrinsic<Intrinsic::assume>())) {
826 if (CondI && SimpleValue::canHandle(CondI)) {
831 LLVM_DEBUG(
dbgs() <<
"EarlyCSE skipping assumption: " << *Inst <<
'\n');
836 if (
match(Inst, m_Intrinsic<Intrinsic::sideeffect>())) {
837 LLVM_DEBUG(
dbgs() <<
"EarlyCSE skipping sideeffect: " << *Inst <<
'\n');
854 if (
match(Inst, m_Intrinsic<Intrinsic::invariant_start>())) {
858 auto *CI = cast<CallInst>(Inst);
861 if (!AvailableInvariants.count(MemLoc))
862 AvailableInvariants.insert(MemLoc, CurrentGeneration);
866 if (
match(Inst, m_Intrinsic<Intrinsic::experimental_guard>())) {
868 dyn_cast<Instruction>(cast<CallInst>(Inst)->getArgOperand(0))) {
869 if (SimpleValue::canHandle(CondI)) {
871 if (
auto *KnownCond = AvailableValues.lookup(CondI)) {
873 if (isa<ConstantInt>(KnownCond) &&
874 cast<ConstantInt>(KnownCond)->isOne()) {
876 <<
"EarlyCSE removing guard: " << *Inst <<
'\n');
883 cast<CallInst>(Inst)->setArgOperand(0, KnownCond);
901 LLVM_DEBUG(
dbgs() <<
"EarlyCSE Simplify: " << *Inst <<
" to: " << *V
925 if (SimpleValue::canHandle(Inst)) {
927 if (
Value *V = AvailableValues.lookup(Inst)) {
934 if (
auto *I = dyn_cast<Instruction>(V))
945 AvailableValues.insert(Inst, Inst);
949 ParseMemoryInst MemInst(Inst, TTI);
951 if (MemInst.isValid() && MemInst.isLoad()) {
954 if (MemInst.isVolatile() || !MemInst.isUnordered()) {
959 if (MemInst.isInvariantLoad()) {
966 if (!AvailableInvariants.count(MemLoc))
967 AvailableInvariants.insert(MemLoc, CurrentGeneration);
977 LoadValue InVal = AvailableLoads.lookup(MemInst.getPointerOperand());
978 if (InVal.DefInst !=
nullptr &&
979 InVal.MatchingId == MemInst.getMatchingId() &&
981 !MemInst.isVolatile() && MemInst.isUnordered() &&
983 InVal.IsAtomic >= MemInst.isAtomic() &&
984 (isOperatingOnInvariantMemAt(Inst, InVal.Generation) ||
985 isSameMemGeneration(InVal.Generation, CurrentGeneration,
986 InVal.DefInst, Inst))) {
990 <<
" to: " << *InVal.DefInst <<
'\n');
1006 AvailableLoads.insert(
1007 MemInst.getPointerOperand(),
1008 LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId(),
1009 MemInst.isAtomic()));
1010 LastStore =
nullptr;
1021 !(MemInst.isValid() && !MemInst.mayReadFromMemory()))
1022 LastStore =
nullptr;
1025 if (CallValue::canHandle(Inst)) {
1028 std::pair<Instruction *, unsigned> InVal = AvailableCalls.lookup(Inst);
1029 if (InVal.first !=
nullptr &&
1030 isSameMemGeneration(InVal.second, CurrentGeneration, InVal.first,
1033 <<
" to: " << *InVal.first <<
'\n');
1048 AvailableCalls.insert(
1049 Inst, std::pair<Instruction *, unsigned>(Inst, CurrentGeneration));
1058 if (
FenceInst *FI = dyn_cast<FenceInst>(Inst))
1069 if (MemInst.isValid() && MemInst.isStore()) {
1070 LoadValue InVal = AvailableLoads.lookup(MemInst.getPointerOperand());
1071 if (InVal.DefInst &&
1072 InVal.DefInst == getOrCreateResult(Inst, InVal.DefInst->getType()) &&
1073 InVal.MatchingId == MemInst.getMatchingId() &&
1075 !MemInst.isVolatile() && MemInst.isUnordered() &&
1076 (isOperatingOnInvariantMemAt(Inst, InVal.Generation) ||
1077 isSameMemGeneration(InVal.Generation, CurrentGeneration,
1078 InVal.DefInst, Inst))) {
1085 MemInst.getPointerOperand() ||
1087 "can't have an intervening store if not using MemorySSA!");
1088 LLVM_DEBUG(
dbgs() <<
"EarlyCSE DSE (writeback): " << *Inst <<
'\n');
1107 ++CurrentGeneration;
1109 if (MemInst.isValid() && MemInst.isStore()) {
1118 ParseMemoryInst LastStoreMemInst(LastStore, TTI);
1119 assert(LastStoreMemInst.isUnordered() &&
1120 !LastStoreMemInst.isVolatile() &&
1121 "Violated invariant");
1122 if (LastStoreMemInst.isMatchingMemLoc(MemInst)) {
1124 <<
" due to: " << *Inst <<
'\n');
1128 removeMSSA(LastStore);
1132 LastStore =
nullptr;
1143 AvailableLoads.insert(
1144 MemInst.getPointerOperand(),
1145 LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId(),
1146 MemInst.isAtomic()));
1155 if (MemInst.isUnordered() && !MemInst.isVolatile())
1158 LastStore =
nullptr;
1166 bool EarlyCSE::run() {
1172 std::deque<StackNode *> nodesToProcess;
1174 bool Changed =
false;
1177 nodesToProcess.push_back(
new StackNode(
1178 AvailableValues, AvailableLoads, AvailableInvariants, AvailableCalls,
1179 CurrentGeneration, DT.getRootNode(),
1180 DT.getRootNode()->begin(), DT.getRootNode()->end()));
1183 unsigned LiveOutGeneration = CurrentGeneration;
1186 while (!nodesToProcess.empty()) {
1189 StackNode *NodeToProcess = nodesToProcess.back();
1192 CurrentGeneration = NodeToProcess->currentGeneration();
1195 if (!NodeToProcess->isProcessed()) {
1197 Changed |= processNode(NodeToProcess->node());
1198 NodeToProcess->childGeneration(CurrentGeneration);
1199 NodeToProcess->process();
1200 }
else if (NodeToProcess->childIter() != NodeToProcess->end()) {
1203 nodesToProcess.push_back(
1204 new StackNode(AvailableValues, AvailableLoads, AvailableInvariants,
1205 AvailableCalls, NodeToProcess->childGeneration(),
1206 child, child->
begin(), child->
end()));
1210 delete NodeToProcess;
1211 nodesToProcess.pop_back();
1216 CurrentGeneration = LiveOutGeneration;
1252 template<
bool UseMemorySSA>
1265 if (skipFunction(F))
1268 auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
1269 auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
1270 auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1271 auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1273 UseMemorySSA ? &getAnalysis<MemorySSAWrapperPass>().getMSSA() :
nullptr;
1309 using EarlyCSEMemSSALegacyPass =
1310 EarlyCSELegacyCommonPass<
true>;
1313 char EarlyCSEMemSSALegacyPass::
ID = 0;
1317 return new EarlyCSEMemSSALegacyPass();
1323 "Early CSE w/ MemorySSA",
false,
false)
Legacy wrapper pass to provide the GlobalsAAResult object.
void initializeEarlyCSELegacyPassPass(PassRegistry &)
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
const_iterator end(StringRef path)
Get end iterator over path.
static ConstantInt * getFalse(LLVMContext &Context)
static SimpleValue getTombstoneKey()
This class is the base class for the comparison instructions.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Value * getPointerOperand(Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
Atomic ordering constants.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Compute iterated dominance frontiers using a linear time algorithm.
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
This is the interface for a simple mod/ref and alias analysis over globals.
An instruction for ordering other memory operations.
value_op_iterator value_op_begin()
This class represents a function call, abstracting a target machine's calling convention.
An immutable pass that tracks lazily created AssumptionCache objects.
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
A cache of @llvm.assume calls within a function.
Analysis pass providing the TargetTransformInfo.
bool salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage debug users of I by writing the...
static CallValue getTombstoneKey()
value_op_iterator value_op_end()
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
BasicBlock * getSuccessor(unsigned i) const
STATISTIC(NumFunctions, "Total number of functions")
Analysis pass which computes a DominatorTree.
block Block Frequency true
An instruction for reading from memory.
Value * getCondition() const
This defines the Use class.
static Optional< MemoryLocation > getOrNone(const Instruction *Inst)
unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT, const BasicBlockEdge &Edge)
Replace each use of 'From' with 'To' if that use is dominated by the given edge.
LLVMContext & getContext() const
Get the context in which this basic block lives.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
iterator begin()
Instruction iterator methods.
bool isIdenticalTo(const Instruction *I) const
Return true if the specified instruction is exactly identical to the current one. ...
bool match(Val *V, const Pattern &P)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Legacy analysis pass which computes MemorySSA.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This is the base class for all instructions that perform data casts.
A Use represents the edge between a Value definition and its users.
separate const offset from Split GEPs to a variadic base and a constant offset for better CSE
Encapsulates MemorySSA, including all data associated with memory accesses.
static bool isLoad(int Opcode)
static CallValue getEmptyKey()
RecyclingAllocator - This class wraps an Allocator, adding the functionality of recycling deleted obj...
This file provides an implementation of debug counters.
static void cse(BasicBlock *BB)
Perform cse of induction variable instructions.
Type * getType() const
All values are typed, get the type of this value.
bool insert(const value_type &X)
Insert a new element into the SetVector.
static bool isEqual(const Function &Caller, const Function &Callee)
This file provides the interface for a simple, fast CSE pass.
void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction...
static bool isStore(int Opcode)
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Value * getLoadStorePointerOperand(Value *V)
A helper function that returns the pointer operand of a load or store instruction.
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Optimize for code generation
INITIALIZE_PASS_BEGIN(EarlyCSELegacyPass, "early-cse", "Early CSE", false, false) using EarlyCSEMemSSALegacyPass
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Value * getOperand(unsigned i) const
bool isVoidTy() const
Return true if this is 'void'.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
static bool runOnFunction(Function &F, bool PostInlining)
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A set of analyses that are preserved following a run of a transformation pass.
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
bool isIdenticalToWhenDefined(const Instruction *I) const
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags, which may specify conditions under which the instruction's result is undefined.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Conditional or Unconditional Branch instruction.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static SimpleValue getEmptyKey()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool mayThrow() const
Return true if this instruction may throw an exception.
Represent the analysis usage information of a pass.
Analysis pass providing a never-invalidated alias analysis result.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
FunctionPass class - This class is used to implement most global optimizations.
static bool shouldExecute(unsigned CounterName)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static bool isAtomic(Instruction *I)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
static MemoryLocation getForArgument(ImmutableCallSite CS, unsigned ArgIdx, const TargetLibraryInfo &TLI)
Return a location representing a particular argument of a call.
MemoryUseOrDef * getMemoryAccess(const Instruction *) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
Representation for a specific memory location.
A function analysis which provides an AssumptionCache.
A SetVector that performs no allocations if smaller than a certain size.
Iterator for intrusive lists based on ilist_node.
SelectPatternFlavor Flavor
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SelectPatternFlavor
Specific patterns of select instructions we can match.
Provides information about what library functions are available for the current target.
An analysis that produces MemorySSA for a function.
LLVM_NODISCARD T pop_back_val()
bool isConditional() const
void setPreservesCFG()
This function should be called by the pass, iff they do not:
static ConstantInt * getTrue(LLVMContext &Context)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
iterator_range< user_iterator > users()
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Represents analyses that only rely on functions' control flow.
Predicate getPredicate() const
Return the predicate for this instruction.
LLVM_NODISCARD bool empty() const
void preserveSet()
Mark an analysis set as preserved.
StringRef getName() const
Return a constant reference to the value's name.
bool mayReadFromMemory() const
Return true if this instruction may read memory.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void preserve()
Mark an analysis as preserved.
DEBUG_COUNTER(CSECounter, "early-cse", "Controls which instructions are removed")
EarlyCSELegacyCommonPass< false > EarlyCSELegacyPass
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isSentinel(const DWARFDebugNames::AttributeEncoding &AE)
Module * getParent()
Get the module that this global value is contained inside of...
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction has no side ef...
LLVM Value Representation.
SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
typename std::vector< DomTreeNodeBase *>::iterator iterator
void initializeEarlyCSEMemSSALegacyPassPass(PassRegistry &)
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
static bool isVolatile(Instruction *Inst)
Represents phi nodes for memory accesses.
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
This header defines various interfaces for pass management in LLVM.
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
Information about a load/store intrinsic defined by the target.
A wrapper class for inspecting calls to intrinsic functions.
This instruction inserts a struct field of array element value into an aggregate value.