llvm::PeelSingleBlockLoop

Peels a single block loop.

Synopsis

Declared in <llvm/CodeGen/MachineLoopUtils.h>

MachineBasicBlock*
PeelSingleBlockLoop(
    LoopPeelDirection Direction,
    MachineBasicBlock* Loop,
    MachineRegisterInfo& MRI,
    TargetInstrInfo const* TII);

Description

Loop must have two successors, one of which must be itself. Similarly it must have two predecessors, one of which must be itself.

The loop block is copied and inserted into the CFG such that two copies of the loop follow on from each other. The copy is inserted either before or after the loop based on Direction.

Phis are updated and an unconditional branch inserted at the end of the clone so as to execute a single iteration.

The trip count of Loop is not updated.

Return Value

The newly created peeled copy of the loop block.

Parameters

NameDescription
DirectionWhether to peel the first or last iteration.
LoopThe single-block loop to peel.
MRIRegister information used when updating phis and clones.
TIITarget instruction info used to insert the exit branch.