Go to the documentation of this file.
15 #ifndef LLVM_TRANSFORMS_SCALAR_GVN_H
16 #define LLVM_TRANSFORMS_SCALAR_GVN_H
36 class AssumptionCache;
40 class ExtractValueInst;
43 class GetElementPtrInst;
44 class ImplicitControlFlowTracking;
48 class MemoryDependenceResults;
50 class MemorySSAUpdater;
51 class NonLocalDepResult;
52 class OptimizationRemarkEmitter;
54 class TargetLibraryInfo;
60 struct AvailableValue;
61 struct AvailableValueInBlock;
128 function_ref<StringRef(StringRef)> MapClassName2PassName);
134 InstrsToErase.push_back(
I);
160 std::vector<Expression> Expressions;
161 std::vector<uint32_t> ExprIdx;
187 std::pair<uint32_t, bool> assignExpNewValueNum(
Expression &exp);
234 struct LeaderTableEntry {
237 LeaderTableEntry *Next;
255 bool InvalidBlockRPONumbers =
true;
268 LeaderTableEntry &Curr = LeaderTable[
N];
275 LeaderTableEntry *
Node = TableAllocator.
Allocate<LeaderTableEntry>();
278 Node->Next = Curr.Next;
285 LeaderTableEntry *Prev =
nullptr;
286 LeaderTableEntry *Curr = &LeaderTable[
N];
288 while (Curr && (Curr->Val !=
I || Curr->BB !=
BB)) {
297 Prev->Next = Curr->Next;
303 LeaderTableEntry *Next = Curr->Next;
304 Curr->Val = Next->Val;
306 Curr->Next = Next->Next;
312 SmallVector<std::pair<Instruction *, unsigned>, 4> toSplit;
315 bool processLoad(LoadInst *L);
316 bool processNonLocalLoad(LoadInst *L);
317 bool processAssumeIntrinsic(AssumeInst *II);
322 bool AnalyzeLoadAvailability(LoadInst *
Load, MemDepResult DepInfo,
323 Value *Address, gvn::AvailableValue &Res);
328 void AnalyzeLoadAvailability(LoadInst *
Load, LoadDepVect &Deps,
329 AvailValInBlkVect &ValuesPerBlock,
330 UnavailBlkVect &UnavailableBlocks);
332 bool PerformLoadPRE(LoadInst *
Load, AvailValInBlkVect &ValuesPerBlock,
333 UnavailBlkVect &UnavailableBlocks);
338 bool performLoopLoadPRE(LoadInst *
Load, AvailValInBlkVect &ValuesPerBlock,
339 UnavailBlkVect &UnavailableBlocks);
343 void eliminatePartiallyRedundantLoad(
344 LoadInst *
Load, AvailValInBlkVect &ValuesPerBlock,
345 MapVector<BasicBlock *, Value *> &AvailableLoads);
348 bool processInstruction(Instruction *
I);
350 void dump(DenseMap<uint32_t, Value *> &
d)
const;
351 bool iterateOnFunction(Function &
F);
352 bool performPRE(Function &
F);
353 bool performScalarPRE(Instruction *
I);
354 bool performScalarPREInsertion(Instruction *Instr,
BasicBlock *Pred,
357 void cleanupGlobalSets();
358 void verifyRemoved(
const Instruction *
I)
const;
359 bool splitCriticalEdges();
361 bool replaceOperandsForInBlockEquality(Instruction *
I)
const;
363 bool DominatesByEdge);
364 bool processFoldableCondBr(BranchInst *BI);
366 void assignValNumForDeadCode();
367 void assignBlockRPONumber(Function &
F);
390 #endif // LLVM_TRANSFORMS_SCALAR_GVN_H
A set of parameters to control various transforms performed by GVN pass.
A set of analyses that are preserved following a run of a transformation pass.
This class allows to keep track on instructions with implicit control flow.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
void clear()
Remove all entries from the ValueTable.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
A CRTP mix-in to automatically provide informational APIs needed for passes.
uint32_t lookupOrAdd(Value *V)
lookup_or_add - Returns the value number for the specified value, assigning it a new number if it did...
A simple and fast domtree-based GVN pass to hoist common expressions from sibling branches.
bool exists(Value *V) const
Returns true if a value number exists for the specified value.
uint32_t lookup(Value *V, bool Verify=true) const
Returns the value number of the specified value.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Optional< bool > AllowLoadInLoopPRE
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
void setMemDep(MemoryDependenceResults *M)
GVNOptions & setLoadInLoopPRE(bool LoadInLoopPRE)
GVNPass(GVNOptions Options={})
FunctionPass * createGVNPass(bool NoMemDepAnalysis=false)
Create a legacy GVN pass.
void eraseTranslateCacheEntry(uint32_t Num, const BasicBlock &CurrBlock)
Erase stale entry from phiTranslate cache so phiTranslate can be computed again.
AAResults * getAliasAnalysis() const
LLVM Basic Block Representation.
ppc ctr loops PowerPC CTR Loops Verify
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
An information struct used to provide DenseMap with the various necessary components for a given valu...
ValueTable & operator=(const ValueTable &Arg)
uint32_t getNextUnusedValueNumber()
GVNOptions & setLoadPRESplitBackedge(bool LoadPRESplitBackedge)
Enables or disables PRE of loads in GVN.
(vector float) vec_cmpeq(*A, *B) C
GVNOptions & setMemDep(bool MemDep)
Enables or disables use of MemDepAnalysis.
Uses an "inverted" value numbering to decide the similarity of expressions and sinks similar expressi...
bool isLoadInLoopPREEnabled() const
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
AAResults * getAliasAnalysis() const
bool isPREEnabled() const
void add(Value *V, uint32_t num)
add - Insert a value into the table with a specified value number.
A MapVector that performs no allocations if smaller than a certain size.
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
bool isLoadPRESplitBackedgeEnabled() const
DominatorTree & getDominatorTree() const
MemoryDependenceResults & getMemDep() const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
void erase(Value *v)
Remove a value from the value numbering.
Allocate memory in an ever growing pool, as if by bump-pointer.
Encapsulates MemorySSA, including all data associated with memory accesses.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
bool isMemDepEnabled() const
uint32_t lookupOrAddCmp(unsigned Opcode, CmpInst::Predicate Pred, Value *LHS, Value *RHS)
Returns the value number of the given comparison, assigning it a new number if it did not have one be...
@ BasicBlock
Various leaf nodes.
void markInstructionForDeletion(Instruction *I)
This removes the specified instruction from our various maps and marks it for deletion.
bool isLoadPREEnabled() const
A cache of @llvm.assume calls within a function.
Optional< bool > AllowPRE
void verifyRemoved(const Value *) const
verifyRemoved - Verify that the value is removed from all internal data structures.
Optional< bool > AllowLoadPRE
This class holds the mapping between values and value numbers.
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library,...
Provides a lazy, caching interface for making common memory aliasing information queries,...
void setDomTree(DominatorTree *D)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Provides information about what library functions are available for the current target.
GVNOptions & setLoadPRE(bool LoadPRE)
Enables or disables PRE of loads in GVN.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
void setAliasAnalysis(AAResults *A)
Optional< bool > AllowLoadPRESplitBackedge
GVNOptions & setPRE(bool PRE)
Enables or disables PRE in GVN.
Optional< bool > AllowMemDep
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
uint32_t phiTranslate(const BasicBlock *BB, const BasicBlock *PhiBlock, uint32_t Num, GVNPass &Gvn)
Wrap phiTranslateImpl to provide caching functionality.
A container for analyses that lazily runs them and caches their results.
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
The core GVN pass object.
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int int d
A vector that has set insertion semantics.
early cse Early CSE w MemorySSA
LLVM Value Representation.