llvm::foldBranchToCommonDest

Fold a setcc-and-branch block into a predecessor that already targets both.

Synopsis

Declared in <llvm/Transforms/Utils/Local.h>

bool
foldBranchToCommonDest(
    CondBrInst* BI,
    llvm::DomTreeUpdater* DTU = nullptr,
    MemorySSAUpdater* MSSAU = nullptr,
    TargetTransformInfo const* TTI = nullptr,
    AssumptionCache* AC = nullptr,
    unsigned int BonusInstThreshold = 1);

Description

If this basic block is ONLY a setcc and a branch, and if a predecessor branches to us and one of our successors, fold the setcc into the predecessor and use logical operations to pick the right destination.

Return Value

True if the branch was folded into a predecessor.

Parameters

NameDescription
BIConditional branch that may be folded into a predecessor.
DTUOptional dominator-tree updater for CFG changes.
MSSAUOptional MemorySSA updater for moved or deleted instructions.
TTIOptional target transform info used for profitability checks.
ACOptional assumption cache used during folding.
BonusInstThresholdMaximum bonus instructions allowed when folding.