29 #define DEBUG_TYPE "div-rem-pairs" 30 STATISTIC(NumPairs,
"Number of div/rem pairs");
31 STATISTIC(NumHoisted,
"Number of instructions hoisted");
32 STATISTIC(NumDecomposed,
"Number of instructions decomposed");
34 "Controls transformations in div-rem-pairs pass");
62 if (
I.getOpcode() == Instruction::SDiv)
64 else if (
I.getOpcode() == Instruction::UDiv)
66 else if (
I.getOpcode() == Instruction::SRem)
68 else if (
I.getOpcode() == Instruction::URem)
76 for (
auto &RemPair : RemMap) {
86 bool IsSigned = DivInst->
getOpcode() == Instruction::SDiv;
95 bool DivDominates = DT.
dominates(DivInst, RemInst);
96 if (!DivDominates && !DT.
dominates(RemInst, DivInst))
117 Instruction *Sub = BinaryOperator::CreateSub(X, Mul);
187 auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
188 auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
196 "Hoist/decompose integer division and remainder",
false,
203 return new DivRemPairsLegacyPass();
Legacy wrapper pass to provide the GlobalsAAResult object.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
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...
static bool optimizeDivRem(Function &F, const TargetTransformInfo &TTI, const DominatorTree &DT)
Find matching pairs of integer div/rem ops (they have the same numerator, denominator, and signedness).
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
This is the interface for a simple mod/ref and alias analysis over globals.
Analysis pass providing the TargetTransformInfo.
void initializeDivRemPairsLegacyPassPass(PassRegistry &)
This class implements a map that also provides access to all stored values in a deterministic order...
STATISTIC(NumFunctions, "Total number of functions")
Analysis pass which computes a DominatorTree.
INITIALIZE_PASS_BEGIN(DivRemPairsLegacyPass, "div-rem-pairs", "Hoist/decompose integer division and remainder", false, false) INITIALIZE_PASS_END(DivRemPairsLegacyPass
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
This file provides an implementation of debug counters.
div rem Hoist decompose integer division and remainder
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Type * getType() const
All values are typed, get the type of this value.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
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...
Value * getOperand(unsigned i) const
static bool runOnFunction(Function &F, bool PostInlining)
A set of analyses that are preserved following a run of a transformation pass.
FunctionPass * createDivRemPairsPass()
Represent the analysis usage information of a pass.
Analysis pass providing a never-invalidated alias analysis result.
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.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
DEBUG_COUNTER(DRPCounter, "div-rem-pairs-transform", "Controls transformations in div-rem-pairs pass")
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
void preserveSet()
Mark an analysis set as preserved.
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction...
void preserve()
Mark an analysis as preserved.
void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
LLVM Value Representation.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
static BinaryOperator * CreateMul(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
const BasicBlock * getParent() const