9#ifndef LLVM_LIB_CODEGEN_BRANCHFOLDING_H
10#define LLVM_LIB_CODEGEN_BRANCHFOLDING_H
33 explicit BranchFolder(
bool DefaultEnableTailMerge,
bool CommonHoist,
39 unsigned MinTailLength = 0);
47 bool AfterPlacement =
false);
50 class MergePotentialsElt {
57 : Hash(h),
Block(b), BranchDebugLoc(std::move(bdl)) {}
59 unsigned getHash()
const {
return Hash; }
66 const DebugLoc &getBranchDebugLoc() {
return BranchDebugLoc; }
68 bool operator<(
const MergePotentialsElt &)
const;
71 using MPIterator = std::vector<MergePotentialsElt>::iterator;
73 std::vector<MergePotentialsElt> MergePotentials;
83 : MPIter(mp), TailStartPos(tsp) {}
85 MPIterator getMPIter()
const {
89 MergePotentialsElt &getMergePotentialsElt()
const {
97 unsigned getHash()
const {
98 return getMergePotentialsElt().getHash();
102 return getMergePotentialsElt().getBlock();
105 bool tailIsWholeBlock()
const {
106 return TailStartPos == getBlock()->begin();
110 getMergePotentialsElt().setBlock(
MBB);
117 std::vector<SameTailElt> SameTails;
119 bool AfterBlockPlacement =
false;
120 bool EnableTailMerge =
false;
121 bool EnableHoistCommonCode =
false;
122 bool UpdateLiveIns =
false;
123 unsigned MinCommonTailLength;
138 unsigned MinCommonTailLength);
162 unsigned ComputeSameTails(
unsigned CurHash,
unsigned minCommonTailLength,
176 unsigned maxCommonTailLength,
177 unsigned &commonTailIndex);
181 void mergeCommonTails(
unsigned commonTailIndex);
#define LLVM_LIBRARY_VISIBILITY
This file defines the DenseMap class.
bool operator<(const DeltaInfo &LHS, int64_t Delta)
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
This file defines the SmallPtrSet class.
LLVM Basic Block Representation.
bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii, const TargetRegisterInfo *tri, MachineLoopInfo *mli=nullptr, bool AfterPlacement=false)
Perhaps branch folding, tail merging and other CFG optimizations on the given function.
BranchFolder(bool DefaultEnableTailMerge, bool CommonHoist, MBFIWrapper &FreqInfo, const MachineBranchProbabilityInfo &ProbInfo, ProfileSummaryInfo *PSI, unsigned MinTailLength=0)
A set of physical registers with utility functions to track liveness when walking backward/forward th...
MachineInstrBundleIterator< MachineInstr > iterator
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Analysis providing profile information.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This is an optimization pass for GlobalISel generic memory operations.