34 #define DEBUG_TYPE "instsimplify"
36 STATISTIC(NumSimplified,
"Number of redundant instructions removed");
52 if (!ToSimplify->
empty() && !ToSimplify->
count(I))
60 Next->insert(cast<Instruction>(U));
81 }
while (!ToSimplify->
empty());
102 bool runOnFunction(
Function &
F)
override {
107 &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
109 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
111 &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
113 &getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
123 "Remove redundant instructions",
false,
false)
134 return new InstSimplifier();
145 bool Changed =
runImpl(F, SQ, &ORE);
A parsed version of the target data layout string in and methods for querying it. ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
static bool runImpl(Function &F, const SimplifyQuery &SQ, OptimizationRemarkEmitter *ORE)
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of .assume calls within a function.
Analysis pass which computes a DominatorTree.
const TargetLibraryInfo * TLI
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
char & InstructionSimplifierID
INITIALIZE_PASS_BEGIN(InstSimplifier,"instsimplify","Remove redundant instructions", false, false) INITIALIZE_PASS_END(InstSimplifier
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
void initializeInstSimplifierPass(PassRegistry &)
LLVM_NODISCARD bool empty() const
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr)
If the specified value is a trivially dead instruction, delete it.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A function analysis which provides an AssumptionCache.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Provides information about what library functions are available for the current target.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
const BasicBlock & getEntryBlock() const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
iterator_range< user_iterator > users()
Represents analyses that only rely on functions' control flow.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
void preserveSet()
Mark an analysis set as preserved.
Analysis pass providing the TargetLibraryInfo.
iterator_range< df_iterator< T > > depth_first(const T &G)
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
inst_range instructions(Function *F)
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
FunctionPass * createInstructionSimplifierPass()
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.