24#define DEBUG_TYPE "aarch64-redundantcondbranch"
38 return "AArch64 Redundant Conditional Branch Elimination";
41char AArch64RedundantCondBranch::ID = 0;
45 "AArch64 Redundant Conditional Branch Elimination pass",
false,
51 unsigned Opc = MI.getOpcode();
58 if (MI.getOperand(0).getReg() == AArch64::WZR ||
59 MI.getOperand(0).getReg() == AArch64::XZR) {
60 LLVM_DEBUG(dbgs() <<
"Removing redundant branch: " << MI);
61 MachineBasicBlock *Target = TII.getBranchDestBlock(MI);
62 SmallVector<MachineBasicBlock *> Succs(MBB->successors());
65 MBB->removeSuccessor(S);
66 DebugLoc DL = MI.getDebugLoc();
67 while (MBB->rbegin() != &MI)
68 MBB->rbegin()->eraseFromParent();
70 BuildMI(MBB, DL, TII.get(AArch64::B)).addMBB(Target);
79 if (MI.getOperand(0).getReg() == AArch64::WZR ||
80 MI.getOperand(0).getReg() == AArch64::XZR) {
81 LLVM_DEBUG(dbgs() <<
"Removing redundant branch: " << MI);
82 MachineBasicBlock *Target = TII.getBranchDestBlock(MI);
83 MI.getParent()->removeSuccessor(Target);
93bool AArch64RedundantCondBranch::runOnMachineFunction(
MachineFunction &MF) {
100 for (MachineBasicBlock &
MBB : MF)
106 return new AArch64RedundantCondBranch();
const TargetInstrInfo & TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Properties which a MachineFunction may have at a given point in time.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
virtual const TargetInstrInfo * getInstrInfo() const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
FunctionPass * createAArch64RedundantCondBranchPass()