LLVM 22.0.0git
AArch64RedundantCondBranchPass.cpp
Go to the documentation of this file.
1//=- AArch64RedundantCondBranch.cpp - Remove redundant conditional branches -=//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Late in the pipeline, especially with zero phi operands propagated after tail
10// duplications, we can end up with CBZ/CBNZ/TBZ/TBNZ with a zero register. This
11// simple pass looks at the terminators to a block, removing the redundant
12// instructions where necessary.
13//
14//===----------------------------------------------------------------------===//
15
16#include "AArch64.h"
17#include "AArch64InstrInfo.h"
21#include "llvm/Support/Debug.h"
22
23using namespace llvm;
24
25#define DEBUG_TYPE "aarch64-redundantcondbranch"
26
27namespace {
28class AArch64RedundantCondBranch : public MachineFunctionPass {
29public:
30 static char ID;
31 AArch64RedundantCondBranch() : MachineFunctionPass(ID) {}
32
33 bool runOnMachineFunction(MachineFunction &MF) override;
34
35 MachineFunctionProperties getRequiredProperties() const override {
36 return MachineFunctionProperties().setNoVRegs();
37 }
38 StringRef getPassName() const override {
39 return "AArch64 Redundant Conditional Branch Elimination";
40 }
41};
42char AArch64RedundantCondBranch::ID = 0;
43} // namespace
44
45INITIALIZE_PASS(AArch64RedundantCondBranch, "aarch64-redundantcondbranch",
46 "AArch64 Redundant Conditional Branch Elimination pass", false,
47 false)
48
49bool AArch64RedundantCondBranch::runOnMachineFunction(MachineFunction &MF) {
50 if (skipFunction(MF.getFunction()))
51 return false;
52
53 const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
54
55 bool Changed = false;
58 return Changed;
59}
60
62 return new AArch64RedundantCondBranch();
63}
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
MachineBasicBlock & MBB
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
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.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
TargetInstrInfo - Interface to description of machine instruction set.
Changed
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
bool optimizeTerminators(MachineBasicBlock *MBB, const TargetInstrInfo &TII)
FunctionPass * createAArch64RedundantCondBranchPass()