2017-07-27 01:20:35 +02:00
|
|
|
//===- HexagonEarlyIfConv.cpp ---------------------------------------------===//
|
2015-10-06 17:49:14 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-10-06 17:49:14 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This implements a Hexagon-specific if-conversion pass that runs on the
|
|
|
|
// SSA form.
|
|
|
|
// In SSA it is not straightforward to represent instructions that condi-
|
|
|
|
// tionally define registers, since a conditionally-defined register may
|
|
|
|
// only be used under the same condition on which the definition was based.
|
|
|
|
// To avoid complications of this nature, this patch will only generate
|
|
|
|
// predicated stores, and speculate other instructions from the "if-conver-
|
|
|
|
// ted" block.
|
|
|
|
// The code will recognize CFG patterns where a block with a conditional
|
|
|
|
// branch "splits" into a "true block" and a "false block". Either of these
|
|
|
|
// could be omitted (in case of a triangle, for example).
|
|
|
|
// If after conversion of the side block(s) the CFG allows it, the resul-
|
|
|
|
// ting blocks may be merged. If the "join" block contained PHI nodes, they
|
|
|
|
// will be replaced with MUX (or MUX-like) instructions to maintain the
|
|
|
|
// semantics of the PHI.
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
//
|
2017-12-07 11:40:31 +01:00
|
|
|
// %40 = L2_loadrub_io killed %39, 1
|
|
|
|
// %41 = S2_tstbit_i killed %40, 0
|
|
|
|
// J2_jumpt killed %41, <%bb.5>, implicit dead %pc
|
|
|
|
// J2_jump <%bb.4>, implicit dead %pc
|
2017-12-04 18:18:51 +01:00
|
|
|
// Successors according to CFG: %bb.4(62) %bb.5(62)
|
2015-10-06 17:49:14 +02:00
|
|
|
//
|
2017-12-04 18:18:51 +01:00
|
|
|
// %bb.4: derived from LLVM BB %if.then
|
|
|
|
// Predecessors according to CFG: %bb.3
|
2017-12-07 11:40:31 +01:00
|
|
|
// %11 = A2_addp %6, %10
|
2017-11-30 13:12:19 +01:00
|
|
|
// S2_storerd_io %32, 16, %11
|
2017-12-04 18:18:51 +01:00
|
|
|
// Successors according to CFG: %bb.5
|
2015-10-06 17:49:14 +02:00
|
|
|
//
|
2017-12-04 18:18:51 +01:00
|
|
|
// %bb.5: derived from LLVM BB %if.end
|
|
|
|
// Predecessors according to CFG: %bb.3 %bb.4
|
2017-12-07 11:40:31 +01:00
|
|
|
// %12 = PHI %6, <%bb.3>, %11, <%bb.4>
|
|
|
|
// %13 = A2_addp %7, %12
|
|
|
|
// %42 = C2_cmpeqi %9, 10
|
|
|
|
// J2_jumpf killed %42, <%bb.3>, implicit dead %pc
|
|
|
|
// J2_jump <%bb.6>, implicit dead %pc
|
2017-12-04 18:18:51 +01:00
|
|
|
// Successors according to CFG: %bb.6(4) %bb.3(124)
|
2015-10-06 17:49:14 +02:00
|
|
|
//
|
|
|
|
// would become:
|
|
|
|
//
|
2017-12-07 11:40:31 +01:00
|
|
|
// %40 = L2_loadrub_io killed %39, 1
|
|
|
|
// %41 = S2_tstbit_i killed %40, 0
|
|
|
|
// spec-> %11 = A2_addp %6, %10
|
2017-11-30 13:12:19 +01:00
|
|
|
// pred-> S2_pstorerdf_io %41, %32, 16, %11
|
2017-12-07 11:40:31 +01:00
|
|
|
// %46 = PS_pselect %41, %6, %11
|
|
|
|
// %13 = A2_addp %7, %46
|
|
|
|
// %42 = C2_cmpeqi %9, 10
|
|
|
|
// J2_jumpf killed %42, <%bb.3>, implicit dead %pc
|
|
|
|
// J2_jump <%bb.6>, implicit dead %pc
|
2017-12-04 18:18:51 +01:00
|
|
|
// Successors according to CFG: %bb.6 %bb.3
|
2015-10-06 17:49:14 +02:00
|
|
|
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "Hexagon.h"
|
|
|
|
#include "HexagonInstrInfo.h"
|
|
|
|
#include "HexagonSubtarget.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-06-06 13:49:48 +02:00
|
|
|
#include "llvm/ADT/iterator_range.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineDominators.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "llvm/CodeGen/MachineLoopInfo.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2017-11-17 02:07:10 +01:00
|
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/IR/DebugLoc.h"
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include "llvm/Support/BranchProbability.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/Support/Debug.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2015-10-06 17:49:14 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2016-12-14 23:50:46 +01:00
|
|
|
#include <cassert>
|
|
|
|
#include <iterator>
|
2015-10-06 17:49:14 +02:00
|
|
|
|
2017-07-13 22:26:45 +02:00
|
|
|
#define DEBUG_TYPE "hexagon-eif"
|
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
FunctionPass *createHexagonEarlyIfConversion();
|
|
|
|
void initializeHexagonEarlyIfConversionPass(PassRegistry& Registry);
|
2016-12-14 23:50:46 +01:00
|
|
|
|
|
|
|
} // end namespace llvm
|
2015-10-06 17:49:14 +02:00
|
|
|
|
2017-07-27 01:20:35 +02:00
|
|
|
static cl::opt<bool> EnableHexagonBP("enable-hexagon-br-prob", cl::Hidden,
|
2018-03-23 19:00:18 +01:00
|
|
|
cl::init(true), cl::desc("Enable branch probability info"));
|
2017-07-27 01:20:35 +02:00
|
|
|
static cl::opt<unsigned> SizeLimit("eif-limit", cl::init(6), cl::Hidden,
|
|
|
|
cl::desc("Size limit in Hexagon early if-conversion"));
|
|
|
|
static cl::opt<bool> SkipExitBranches("eif-no-loop-exit", cl::init(false),
|
|
|
|
cl::Hidden, cl::desc("Do not convert branches that may exit the loop"));
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2017-07-27 01:20:35 +02:00
|
|
|
namespace {
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
struct PrintMB {
|
|
|
|
PrintMB(const MachineBasicBlock *B) : MB(B) {}
|
2017-07-27 01:20:35 +02:00
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
const MachineBasicBlock *MB;
|
|
|
|
};
|
|
|
|
raw_ostream &operator<< (raw_ostream &OS, const PrintMB &P) {
|
|
|
|
if (!P.MB)
|
|
|
|
return OS << "<none>";
|
|
|
|
return OS << '#' << P.MB->getNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct FlowPattern {
|
2016-12-14 23:50:46 +01:00
|
|
|
FlowPattern() = default;
|
2015-10-06 17:49:14 +02:00
|
|
|
FlowPattern(MachineBasicBlock *B, unsigned PR, MachineBasicBlock *TB,
|
|
|
|
MachineBasicBlock *FB, MachineBasicBlock *JB)
|
|
|
|
: SplitB(B), TrueB(TB), FalseB(FB), JoinB(JB), PredR(PR) {}
|
|
|
|
|
2016-12-14 23:50:46 +01:00
|
|
|
MachineBasicBlock *SplitB = nullptr;
|
|
|
|
MachineBasicBlock *TrueB = nullptr;
|
|
|
|
MachineBasicBlock *FalseB = nullptr;
|
|
|
|
MachineBasicBlock *JoinB = nullptr;
|
|
|
|
unsigned PredR = 0;
|
2015-10-06 17:49:14 +02:00
|
|
|
};
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
struct PrintFP {
|
|
|
|
PrintFP(const FlowPattern &P, const TargetRegisterInfo &T)
|
|
|
|
: FP(P), TRI(T) {}
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
const FlowPattern &FP;
|
|
|
|
const TargetRegisterInfo &TRI;
|
|
|
|
friend raw_ostream &operator<< (raw_ostream &OS, const PrintFP &P);
|
|
|
|
};
|
|
|
|
raw_ostream &operator<<(raw_ostream &OS,
|
|
|
|
const PrintFP &P) LLVM_ATTRIBUTE_UNUSED;
|
|
|
|
raw_ostream &operator<<(raw_ostream &OS, const PrintFP &P) {
|
|
|
|
OS << "{ SplitB:" << PrintMB(P.FP.SplitB)
|
2017-11-28 13:42:37 +01:00
|
|
|
<< ", PredR:" << printReg(P.FP.PredR, &P.TRI)
|
2017-03-06 18:24:04 +01:00
|
|
|
<< ", TrueB:" << PrintMB(P.FP.TrueB)
|
|
|
|
<< ", FalseB:" << PrintMB(P.FP.FalseB)
|
2015-10-06 17:49:14 +02:00
|
|
|
<< ", JoinB:" << PrintMB(P.FP.JoinB) << " }";
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
|
|
|
class HexagonEarlyIfConversion : public MachineFunctionPass {
|
|
|
|
public:
|
|
|
|
static char ID;
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2017-08-09 23:22:05 +02:00
|
|
|
HexagonEarlyIfConversion() : MachineFunctionPass(ID) {}
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2016-10-01 04:56:57 +02:00
|
|
|
StringRef getPassName() const override {
|
2015-10-06 17:49:14 +02:00
|
|
|
return "Hexagon early if conversion";
|
|
|
|
}
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
|
|
AU.addRequired<MachineBranchProbabilityInfo>();
|
|
|
|
AU.addRequired<MachineDominatorTree>();
|
|
|
|
AU.addPreserved<MachineDominatorTree>();
|
|
|
|
AU.addRequired<MachineLoopInfo>();
|
|
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
|
|
|
}
|
2016-12-14 23:50:46 +01:00
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
|
|
|
|
|
|
|
private:
|
2017-07-27 01:20:35 +02:00
|
|
|
using BlockSetType = DenseSet<MachineBasicBlock *>;
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
bool isPreheader(const MachineBasicBlock *B) const;
|
|
|
|
bool matchFlowPattern(MachineBasicBlock *B, MachineLoop *L,
|
|
|
|
FlowPattern &FP);
|
|
|
|
bool visitBlock(MachineBasicBlock *B, MachineLoop *L);
|
|
|
|
bool visitLoop(MachineLoop *L);
|
|
|
|
|
|
|
|
bool hasEHLabel(const MachineBasicBlock *B) const;
|
|
|
|
bool hasUncondBranch(const MachineBasicBlock *B) const;
|
|
|
|
bool isValidCandidate(const MachineBasicBlock *B) const;
|
|
|
|
bool usesUndefVReg(const MachineInstr *MI) const;
|
|
|
|
bool isValid(const FlowPattern &FP) const;
|
|
|
|
unsigned countPredicateDefs(const MachineBasicBlock *B) const;
|
2017-03-06 18:24:04 +01:00
|
|
|
unsigned computePhiCost(const MachineBasicBlock *B,
|
|
|
|
const FlowPattern &FP) const;
|
2015-10-06 17:49:14 +02:00
|
|
|
bool isProfitable(const FlowPattern &FP) const;
|
|
|
|
bool isPredicableStore(const MachineInstr *MI) const;
|
|
|
|
bool isSafeToSpeculate(const MachineInstr *MI) const;
|
2018-03-23 18:46:09 +01:00
|
|
|
bool isPredicate(unsigned R) const;
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
unsigned getCondStoreOpcode(unsigned Opc, bool IfTrue) const;
|
|
|
|
void predicateInstr(MachineBasicBlock *ToB, MachineBasicBlock::iterator At,
|
|
|
|
MachineInstr *MI, unsigned PredR, bool IfTrue);
|
|
|
|
void predicateBlockNB(MachineBasicBlock *ToB,
|
|
|
|
MachineBasicBlock::iterator At, MachineBasicBlock *FromB,
|
|
|
|
unsigned PredR, bool IfTrue);
|
|
|
|
|
2017-03-06 18:24:04 +01:00
|
|
|
unsigned buildMux(MachineBasicBlock *B, MachineBasicBlock::iterator At,
|
|
|
|
const TargetRegisterClass *DRC, unsigned PredR, unsigned TR,
|
|
|
|
unsigned TSR, unsigned FR, unsigned FSR);
|
2015-10-06 17:49:14 +02:00
|
|
|
void updatePhiNodes(MachineBasicBlock *WhereB, const FlowPattern &FP);
|
|
|
|
void convert(const FlowPattern &FP);
|
|
|
|
|
|
|
|
void removeBlock(MachineBasicBlock *B);
|
|
|
|
void eliminatePhis(MachineBasicBlock *B);
|
|
|
|
void mergeBlocks(MachineBasicBlock *PredB, MachineBasicBlock *SuccB);
|
|
|
|
void simplifyFlowGraph(const FlowPattern &FP);
|
|
|
|
|
2017-07-27 01:20:35 +02:00
|
|
|
const HexagonInstrInfo *HII = nullptr;
|
|
|
|
const TargetRegisterInfo *TRI = nullptr;
|
|
|
|
MachineFunction *MFN = nullptr;
|
|
|
|
MachineRegisterInfo *MRI = nullptr;
|
|
|
|
MachineDominatorTree *MDT = nullptr;
|
|
|
|
MachineLoopInfo *MLI = nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
BlockSetType Deleted;
|
|
|
|
const MachineBranchProbabilityInfo *MBPI;
|
|
|
|
};
|
|
|
|
|
2016-12-14 23:50:46 +01:00
|
|
|
} // end anonymous namespace
|
2015-10-06 17:49:14 +02:00
|
|
|
|
2017-07-27 01:20:35 +02:00
|
|
|
char HexagonEarlyIfConversion::ID = 0;
|
|
|
|
|
2017-08-09 23:22:05 +02:00
|
|
|
INITIALIZE_PASS(HexagonEarlyIfConversion, "hexagon-early-if",
|
2015-10-06 17:49:14 +02:00
|
|
|
"Hexagon early if conversion", false, false)
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::isPreheader(const MachineBasicBlock *B) const {
|
|
|
|
if (B->succ_size() != 1)
|
|
|
|
return false;
|
|
|
|
MachineBasicBlock *SB = *B->succ_begin();
|
|
|
|
MachineLoop *L = MLI->getLoopFor(SB);
|
2017-03-06 18:24:04 +01:00
|
|
|
return L && SB == L->getHeader() && MDT->dominates(B, SB);
|
2015-10-06 17:49:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::matchFlowPattern(MachineBasicBlock *B,
|
|
|
|
MachineLoop *L, FlowPattern &FP) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Checking flow pattern at " << printMBBReference(*B)
|
|
|
|
<< "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
// Interested only in conditional branches, no .new, no new-value, etc.
|
|
|
|
// Check the terminators directly, it's easier than handling all responses
|
2018-03-23 19:00:18 +01:00
|
|
|
// from analyzeBranch.
|
2016-12-14 23:50:46 +01:00
|
|
|
MachineBasicBlock *TB = nullptr, *FB = nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
MachineBasicBlock::const_iterator T1I = B->getFirstTerminator();
|
|
|
|
if (T1I == B->end())
|
|
|
|
return false;
|
|
|
|
unsigned Opc = T1I->getOpcode();
|
|
|
|
if (Opc != Hexagon::J2_jumpt && Opc != Hexagon::J2_jumpf)
|
|
|
|
return false;
|
|
|
|
unsigned PredR = T1I->getOperand(0).getReg();
|
|
|
|
|
|
|
|
// Get the layout successor, or 0 if B does not have one.
|
|
|
|
MachineFunction::iterator NextBI = std::next(MachineFunction::iterator(B));
|
2016-12-14 23:50:46 +01:00
|
|
|
MachineBasicBlock *NextB = (NextBI != MFN->end()) ? &*NextBI : nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
MachineBasicBlock *T1B = T1I->getOperand(1).getMBB();
|
|
|
|
MachineBasicBlock::const_iterator T2I = std::next(T1I);
|
|
|
|
// The second terminator should be an unconditional branch.
|
|
|
|
assert(T2I == B->end() || T2I->getOpcode() == Hexagon::J2_jump);
|
|
|
|
MachineBasicBlock *T2B = (T2I == B->end()) ? NextB
|
|
|
|
: T2I->getOperand(0).getMBB();
|
|
|
|
if (T1B == T2B) {
|
|
|
|
// XXX merge if T1B == NextB, or convert branch to unconditional.
|
|
|
|
// mark as diamond with both sides equal?
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Record the true/false blocks in such a way that "true" means "if (PredR)",
|
|
|
|
// and "false" means "if (!PredR)".
|
|
|
|
if (Opc == Hexagon::J2_jumpt)
|
|
|
|
TB = T1B, FB = T2B;
|
|
|
|
else
|
|
|
|
TB = T2B, FB = T1B;
|
|
|
|
|
|
|
|
if (!MDT->properlyDominates(B, TB) || !MDT->properlyDominates(B, FB))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Detect triangle first. In case of a triangle, one of the blocks TB/FB
|
|
|
|
// can fall through into the other, in other words, it will be executed
|
|
|
|
// in both cases. We only want to predicate the block that is executed
|
|
|
|
// conditionally.
|
|
|
|
unsigned TNP = TB->pred_size(), FNP = FB->pred_size();
|
|
|
|
unsigned TNS = TB->succ_size(), FNS = FB->succ_size();
|
|
|
|
|
|
|
|
// A block is predicable if it has one predecessor (it must be B), and
|
|
|
|
// it has a single successor. In fact, the block has to end either with
|
|
|
|
// an unconditional branch (which can be predicated), or with a fall-
|
|
|
|
// through.
|
2017-03-06 18:24:04 +01:00
|
|
|
// Also, skip blocks that do not belong to the same loop.
|
|
|
|
bool TOk = (TNP == 1 && TNS == 1 && MLI->getLoopFor(TB) == L);
|
|
|
|
bool FOk = (FNP == 1 && FNS == 1 && MLI->getLoopFor(FB) == L);
|
|
|
|
|
|
|
|
// If requested (via an option), do not consider branches where the
|
|
|
|
// true and false targets do not belong to the same loop.
|
|
|
|
if (SkipExitBranches && MLI->getLoopFor(TB) != MLI->getLoopFor(FB))
|
|
|
|
return false;
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
// If neither is predicable, there is nothing interesting.
|
|
|
|
if (!TOk && !FOk)
|
|
|
|
return false;
|
|
|
|
|
2016-12-14 23:50:46 +01:00
|
|
|
MachineBasicBlock *TSB = (TNS > 0) ? *TB->succ_begin() : nullptr;
|
|
|
|
MachineBasicBlock *FSB = (FNS > 0) ? *FB->succ_begin() : nullptr;
|
|
|
|
MachineBasicBlock *JB = nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
if (TOk) {
|
|
|
|
if (FOk) {
|
|
|
|
if (TSB == FSB)
|
|
|
|
JB = TSB;
|
|
|
|
// Diamond: "if (P) then TB; else FB;".
|
|
|
|
} else {
|
|
|
|
// TOk && !FOk
|
2017-03-06 18:24:04 +01:00
|
|
|
if (TSB == FB)
|
2015-10-06 17:49:14 +02:00
|
|
|
JB = FB;
|
2017-03-06 18:24:04 +01:00
|
|
|
FB = nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// !TOk && FOk (at least one must be true by now).
|
2017-03-06 18:24:04 +01:00
|
|
|
if (FSB == TB)
|
2015-10-06 17:49:14 +02:00
|
|
|
JB = TB;
|
2017-03-06 18:24:04 +01:00
|
|
|
TB = nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
}
|
|
|
|
// Don't try to predicate loop preheaders.
|
|
|
|
if ((TB && isPreheader(TB)) || (FB && isPreheader(FB))) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "One of blocks " << PrintMB(TB) << ", " << PrintMB(FB)
|
|
|
|
<< " is a loop preheader. Skipping.\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
FP = FlowPattern(B, PredR, TB, FB, JB);
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Detected " << PrintFP(FP, *TRI) << "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-23 19:00:18 +01:00
|
|
|
// KLUDGE: HexagonInstrInfo::analyzeBranch won't work on a block that
|
2015-10-06 17:49:14 +02:00
|
|
|
// contains EH_LABEL.
|
|
|
|
bool HexagonEarlyIfConversion::hasEHLabel(const MachineBasicBlock *B) const {
|
|
|
|
for (auto &I : *B)
|
|
|
|
if (I.isEHLabel())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-23 19:00:18 +01:00
|
|
|
// KLUDGE: HexagonInstrInfo::analyzeBranch may be unable to recognize
|
2015-10-06 17:49:14 +02:00
|
|
|
// that a block can never fall-through.
|
|
|
|
bool HexagonEarlyIfConversion::hasUncondBranch(const MachineBasicBlock *B)
|
|
|
|
const {
|
|
|
|
MachineBasicBlock::const_iterator I = B->getFirstTerminator(), E = B->end();
|
|
|
|
while (I != E) {
|
|
|
|
if (I->isBarrier())
|
|
|
|
return true;
|
|
|
|
++I;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::isValidCandidate(const MachineBasicBlock *B)
|
|
|
|
const {
|
|
|
|
if (!B)
|
|
|
|
return true;
|
|
|
|
if (B->isEHPad() || B->hasAddressTaken())
|
|
|
|
return false;
|
|
|
|
if (B->succ_size() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (auto &MI : *B) {
|
2018-05-09 04:42:00 +02:00
|
|
|
if (MI.isDebugInstr())
|
2015-10-06 17:49:14 +02:00
|
|
|
continue;
|
|
|
|
if (MI.isConditionalBranch())
|
|
|
|
return false;
|
|
|
|
unsigned Opc = MI.getOpcode();
|
|
|
|
bool IsJMP = (Opc == Hexagon::J2_jump);
|
|
|
|
if (!isPredicableStore(&MI) && !IsJMP && !isSafeToSpeculate(&MI))
|
|
|
|
return false;
|
|
|
|
// Look for predicate registers defined by this instruction. It's ok
|
|
|
|
// to speculate such an instruction, but the predicate register cannot
|
|
|
|
// be used outside of this block (or else it won't be possible to
|
|
|
|
// update the use of it after predication). PHI uses will be updated
|
|
|
|
// to use a result of a MUX, and a MUX cannot be created for predicate
|
|
|
|
// registers.
|
2016-10-24 23:36:43 +02:00
|
|
|
for (const MachineOperand &MO : MI.operands()) {
|
|
|
|
if (!MO.isReg() || !MO.isDef())
|
2015-10-06 17:49:14 +02:00
|
|
|
continue;
|
2016-10-24 23:36:43 +02:00
|
|
|
unsigned R = MO.getReg();
|
2019-08-02 01:27:28 +02:00
|
|
|
if (!Register::isVirtualRegister(R))
|
2015-10-06 17:49:14 +02:00
|
|
|
continue;
|
2018-03-23 18:46:09 +01:00
|
|
|
if (!isPredicate(R))
|
|
|
|
continue;
|
2015-10-06 17:49:14 +02:00
|
|
|
for (auto U = MRI->use_begin(R); U != MRI->use_end(); ++U)
|
|
|
|
if (U->getParent()->isPHI())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::usesUndefVReg(const MachineInstr *MI) const {
|
2016-10-24 23:36:43 +02:00
|
|
|
for (const MachineOperand &MO : MI->operands()) {
|
|
|
|
if (!MO.isReg() || !MO.isUse())
|
2015-10-06 17:49:14 +02:00
|
|
|
continue;
|
2016-10-24 23:36:43 +02:00
|
|
|
unsigned R = MO.getReg();
|
2019-08-02 01:27:28 +02:00
|
|
|
if (!Register::isVirtualRegister(R))
|
2015-10-06 17:49:14 +02:00
|
|
|
continue;
|
|
|
|
const MachineInstr *DefI = MRI->getVRegDef(R);
|
|
|
|
// "Undefined" virtual registers are actually defined via IMPLICIT_DEF.
|
|
|
|
assert(DefI && "Expecting a reaching def in MRI");
|
|
|
|
if (DefI->isImplicitDef())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::isValid(const FlowPattern &FP) const {
|
|
|
|
if (hasEHLabel(FP.SplitB)) // KLUDGE: see function definition
|
|
|
|
return false;
|
|
|
|
if (FP.TrueB && !isValidCandidate(FP.TrueB))
|
|
|
|
return false;
|
|
|
|
if (FP.FalseB && !isValidCandidate(FP.FalseB))
|
|
|
|
return false;
|
|
|
|
// Check the PHIs in the join block. If any of them use a register
|
|
|
|
// that is defined as IMPLICIT_DEF, do not convert this. This can
|
|
|
|
// legitimately happen if one side of the split never executes, but
|
|
|
|
// the compiler is unable to prove it. That side may then seem to
|
|
|
|
// provide an "undef" value to the join block, however it will never
|
|
|
|
// execute at run-time. If we convert this case, the "undef" will
|
|
|
|
// be used in a MUX instruction, and that may seem like actually
|
|
|
|
// using an undefined value to other optimizations. This could lead
|
|
|
|
// to trouble further down the optimization stream, cause assertions
|
|
|
|
// to fail, etc.
|
|
|
|
if (FP.JoinB) {
|
|
|
|
const MachineBasicBlock &B = *FP.JoinB;
|
|
|
|
for (auto &MI : B) {
|
|
|
|
if (!MI.isPHI())
|
|
|
|
break;
|
|
|
|
if (usesUndefVReg(&MI))
|
|
|
|
return false;
|
|
|
|
unsigned DefR = MI.getOperand(0).getReg();
|
2018-03-23 18:46:09 +01:00
|
|
|
if (isPredicate(DefR))
|
2015-10-06 17:49:14 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-06 18:24:04 +01:00
|
|
|
unsigned HexagonEarlyIfConversion::computePhiCost(const MachineBasicBlock *B,
|
|
|
|
const FlowPattern &FP) const {
|
2015-10-06 17:49:14 +02:00
|
|
|
if (B->pred_size() < 2)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
unsigned Cost = 0;
|
2017-03-06 18:24:04 +01:00
|
|
|
for (const MachineInstr &MI : *B) {
|
|
|
|
if (!MI.isPHI())
|
|
|
|
break;
|
|
|
|
// If both incoming blocks are one of the TrueB/FalseB/SplitB, then
|
|
|
|
// a MUX may be needed. Otherwise the PHI will need to be updated at
|
|
|
|
// no extra cost.
|
|
|
|
// Find the interesting PHI operands for further checks.
|
|
|
|
SmallVector<unsigned,2> Inc;
|
|
|
|
for (unsigned i = 1, e = MI.getNumOperands(); i != e; i += 2) {
|
|
|
|
const MachineBasicBlock *BB = MI.getOperand(i+1).getMBB();
|
|
|
|
if (BB == FP.SplitB || BB == FP.TrueB || BB == FP.FalseB)
|
|
|
|
Inc.push_back(i);
|
|
|
|
}
|
|
|
|
assert(Inc.size() <= 2);
|
|
|
|
if (Inc.size() < 2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const MachineOperand &RA = MI.getOperand(1);
|
|
|
|
const MachineOperand &RB = MI.getOperand(3);
|
|
|
|
assert(RA.isReg() && RB.isReg());
|
2015-10-06 17:49:14 +02:00
|
|
|
// Must have a MUX if the phi uses a subregister.
|
2017-03-14 16:21:33 +01:00
|
|
|
if (RA.getSubReg() != 0 || RB.getSubReg() != 0) {
|
2015-10-06 17:49:14 +02:00
|
|
|
Cost++;
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-06 18:24:04 +01:00
|
|
|
const MachineInstr *Def1 = MRI->getVRegDef(RA.getReg());
|
|
|
|
const MachineInstr *Def3 = MRI->getVRegDef(RB.getReg());
|
2016-07-26 22:30:30 +02:00
|
|
|
if (!HII->isPredicable(*Def1) || !HII->isPredicable(*Def3))
|
2015-10-06 17:49:14 +02:00
|
|
|
Cost++;
|
|
|
|
}
|
|
|
|
return Cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned HexagonEarlyIfConversion::countPredicateDefs(
|
|
|
|
const MachineBasicBlock *B) const {
|
|
|
|
unsigned PredDefs = 0;
|
|
|
|
for (auto &MI : *B) {
|
2016-10-24 23:36:43 +02:00
|
|
|
for (const MachineOperand &MO : MI.operands()) {
|
|
|
|
if (!MO.isReg() || !MO.isDef())
|
2015-10-06 17:49:14 +02:00
|
|
|
continue;
|
2016-10-24 23:36:43 +02:00
|
|
|
unsigned R = MO.getReg();
|
2019-08-02 01:27:28 +02:00
|
|
|
if (!Register::isVirtualRegister(R))
|
2015-10-06 17:49:14 +02:00
|
|
|
continue;
|
2018-03-23 19:00:18 +01:00
|
|
|
if (isPredicate(R))
|
2015-10-06 17:49:14 +02:00
|
|
|
PredDefs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PredDefs;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::isProfitable(const FlowPattern &FP) const {
|
2018-03-23 19:00:18 +01:00
|
|
|
BranchProbability JumpProb(1, 10);
|
|
|
|
BranchProbability Prob(9, 10);
|
|
|
|
if (MBPI && FP.TrueB && !FP.FalseB &&
|
|
|
|
(MBPI->getEdgeProbability(FP.SplitB, FP.TrueB) < JumpProb ||
|
|
|
|
MBPI->getEdgeProbability(FP.SplitB, FP.TrueB) > Prob))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (MBPI && !FP.TrueB && FP.FalseB &&
|
|
|
|
(MBPI->getEdgeProbability(FP.SplitB, FP.FalseB) < JumpProb ||
|
|
|
|
MBPI->getEdgeProbability(FP.SplitB, FP.FalseB) > Prob))
|
|
|
|
return false;
|
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
if (FP.TrueB && FP.FalseB) {
|
|
|
|
// Do not IfCovert if the branch is one sided.
|
|
|
|
if (MBPI) {
|
|
|
|
if (MBPI->getEdgeProbability(FP.SplitB, FP.TrueB) > Prob)
|
|
|
|
return false;
|
|
|
|
if (MBPI->getEdgeProbability(FP.SplitB, FP.FalseB) > Prob)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If both sides are predicable, convert them if they join, and the
|
|
|
|
// join block has no other predecessors.
|
|
|
|
MachineBasicBlock *TSB = *FP.TrueB->succ_begin();
|
|
|
|
MachineBasicBlock *FSB = *FP.FalseB->succ_begin();
|
|
|
|
if (TSB != FSB)
|
|
|
|
return false;
|
|
|
|
if (TSB->pred_size() != 2)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the total size of the predicated blocks.
|
|
|
|
// Assume instruction counts without branches to be the approximation of
|
|
|
|
// the code size. If the predicated blocks are smaller than a packet size,
|
|
|
|
// approximate the spare room in the packet that could be filled with the
|
|
|
|
// predicated/speculated instructions.
|
2017-04-03 19:26:40 +02:00
|
|
|
auto TotalCount = [] (const MachineBasicBlock *B, unsigned &Spare) {
|
|
|
|
if (!B)
|
|
|
|
return 0u;
|
2017-08-09 23:22:05 +02:00
|
|
|
unsigned T = std::count_if(B->begin(), B->getFirstTerminator(),
|
|
|
|
[](const MachineInstr &MI) {
|
2017-08-10 17:00:30 +02:00
|
|
|
return !MI.isMetaInstruction();
|
2017-08-09 23:22:05 +02:00
|
|
|
});
|
2017-04-03 19:26:40 +02:00
|
|
|
if (T < HEXAGON_PACKET_SIZE)
|
|
|
|
Spare += HEXAGON_PACKET_SIZE-T;
|
|
|
|
return T;
|
|
|
|
};
|
|
|
|
unsigned Spare = 0;
|
|
|
|
unsigned TotalIn = TotalCount(FP.TrueB, Spare) + TotalCount(FP.FalseB, Spare);
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(
|
|
|
|
dbgs() << "Total number of instructions to be predicated/speculated: "
|
|
|
|
<< TotalIn << ", spare room: " << Spare << "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
if (TotalIn >= SizeLimit+Spare)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Count the number of PHI nodes that will need to be updated (converted
|
|
|
|
// to MUX). Those can be later converted to predicated instructions, so
|
|
|
|
// they aren't always adding extra cost.
|
|
|
|
// KLUDGE: Also, count the number of predicate register definitions in
|
|
|
|
// each block. The scheduler may increase the pressure of these and cause
|
|
|
|
// expensive spills (e.g. bitmnp01).
|
|
|
|
unsigned TotalPh = 0;
|
|
|
|
unsigned PredDefs = countPredicateDefs(FP.SplitB);
|
|
|
|
if (FP.JoinB) {
|
2017-03-06 18:24:04 +01:00
|
|
|
TotalPh = computePhiCost(FP.JoinB, FP);
|
2015-10-06 17:49:14 +02:00
|
|
|
PredDefs += countPredicateDefs(FP.JoinB);
|
|
|
|
} else {
|
|
|
|
if (FP.TrueB && FP.TrueB->succ_size() > 0) {
|
|
|
|
MachineBasicBlock *SB = *FP.TrueB->succ_begin();
|
2017-03-06 18:24:04 +01:00
|
|
|
TotalPh += computePhiCost(SB, FP);
|
2015-10-06 17:49:14 +02:00
|
|
|
PredDefs += countPredicateDefs(SB);
|
|
|
|
}
|
|
|
|
if (FP.FalseB && FP.FalseB->succ_size() > 0) {
|
|
|
|
MachineBasicBlock *SB = *FP.FalseB->succ_begin();
|
2017-03-06 18:24:04 +01:00
|
|
|
TotalPh += computePhiCost(SB, FP);
|
2015-10-06 17:49:14 +02:00
|
|
|
PredDefs += countPredicateDefs(SB);
|
|
|
|
}
|
|
|
|
}
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Total number of extra muxes from converted phis: "
|
|
|
|
<< TotalPh << "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
if (TotalIn+TotalPh >= SizeLimit+Spare)
|
|
|
|
return false;
|
|
|
|
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Total number of predicate registers: " << PredDefs
|
|
|
|
<< "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
if (PredDefs > 4)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::visitBlock(MachineBasicBlock *B,
|
|
|
|
MachineLoop *L) {
|
|
|
|
bool Changed = false;
|
|
|
|
|
|
|
|
// Visit all dominated blocks from the same loop first, then process B.
|
|
|
|
MachineDomTreeNode *N = MDT->getNode(B);
|
2017-07-27 01:20:35 +02:00
|
|
|
|
|
|
|
using GTN = GraphTraits<MachineDomTreeNode *>;
|
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
// We will change CFG/DT during this traversal, so take precautions to
|
|
|
|
// avoid problems related to invalidated iterators. In fact, processing
|
|
|
|
// a child C of B cannot cause another child to be removed, but it can
|
|
|
|
// cause a new child to be added (which was a child of C before C itself
|
|
|
|
// was removed. This new child C, however, would have been processed
|
|
|
|
// prior to processing B, so there is no need to process it again.
|
|
|
|
// Simply keep a list of children of B, and traverse that list.
|
2017-07-27 01:20:35 +02:00
|
|
|
using DTNodeVectType = SmallVector<MachineDomTreeNode *, 4>;
|
2015-10-06 17:49:14 +02:00
|
|
|
DTNodeVectType Cn(GTN::child_begin(N), GTN::child_end(N));
|
|
|
|
for (DTNodeVectType::iterator I = Cn.begin(), E = Cn.end(); I != E; ++I) {
|
|
|
|
MachineBasicBlock *SB = (*I)->getBlock();
|
|
|
|
if (!Deleted.count(SB))
|
|
|
|
Changed |= visitBlock(SB, L);
|
|
|
|
}
|
|
|
|
// When walking down the dominator tree, we want to traverse through
|
|
|
|
// blocks from nested (other) loops, because they can dominate blocks
|
|
|
|
// that are in L. Skip the non-L blocks only after the tree traversal.
|
|
|
|
if (MLI->getLoopFor(B) != L)
|
|
|
|
return Changed;
|
|
|
|
|
|
|
|
FlowPattern FP;
|
|
|
|
if (!matchFlowPattern(B, L, FP))
|
|
|
|
return Changed;
|
|
|
|
|
|
|
|
if (!isValid(FP)) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Conversion is not valid\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
return Changed;
|
|
|
|
}
|
|
|
|
if (!isProfitable(FP)) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Conversion is not profitable\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
return Changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
convert(FP);
|
|
|
|
simplifyFlowGraph(FP);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::visitLoop(MachineLoop *L) {
|
2016-12-14 23:50:46 +01:00
|
|
|
MachineBasicBlock *HB = L ? L->getHeader() : nullptr;
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG((L ? dbgs() << "Visiting loop H:" << PrintMB(HB)
|
|
|
|
: dbgs() << "Visiting function")
|
|
|
|
<< "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
bool Changed = false;
|
|
|
|
if (L) {
|
|
|
|
for (MachineLoop::iterator I = L->begin(), E = L->end(); I != E; ++I)
|
|
|
|
Changed |= visitLoop(*I);
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineBasicBlock *EntryB = GraphTraits<MachineFunction*>::getEntryNode(MFN);
|
|
|
|
Changed |= visitBlock(L ? HB : EntryB, L);
|
|
|
|
return Changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::isPredicableStore(const MachineInstr *MI)
|
|
|
|
const {
|
2016-07-26 22:30:30 +02:00
|
|
|
// HexagonInstrInfo::isPredicable will consider these stores are non-
|
|
|
|
// -predicable if the offset would become constant-extended after
|
|
|
|
// predication.
|
2015-10-06 17:49:14 +02:00
|
|
|
unsigned Opc = MI->getOpcode();
|
|
|
|
switch (Opc) {
|
2016-07-26 22:30:30 +02:00
|
|
|
case Hexagon::S2_storerb_io:
|
|
|
|
case Hexagon::S2_storerbnew_io:
|
|
|
|
case Hexagon::S2_storerh_io:
|
|
|
|
case Hexagon::S2_storerhnew_io:
|
|
|
|
case Hexagon::S2_storeri_io:
|
|
|
|
case Hexagon::S2_storerinew_io:
|
|
|
|
case Hexagon::S2_storerd_io:
|
|
|
|
case Hexagon::S4_storeirb_io:
|
|
|
|
case Hexagon::S4_storeirh_io:
|
|
|
|
case Hexagon::S4_storeiri_io:
|
2015-10-06 17:49:14 +02:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-26 22:30:30 +02:00
|
|
|
|
|
|
|
// TargetInstrInfo::isPredicable takes a non-const pointer.
|
|
|
|
return MI->mayStore() && HII->isPredicable(const_cast<MachineInstr&>(*MI));
|
2015-10-06 17:49:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::isSafeToSpeculate(const MachineInstr *MI)
|
|
|
|
const {
|
|
|
|
if (MI->mayLoad() || MI->mayStore())
|
|
|
|
return false;
|
|
|
|
if (MI->isCall() || MI->isBarrier() || MI->isBranch())
|
|
|
|
return false;
|
|
|
|
if (MI->hasUnmodeledSideEffects())
|
|
|
|
return false;
|
2018-03-23 18:46:09 +01:00
|
|
|
if (MI->getOpcode() == TargetOpcode::LIFETIME_END)
|
|
|
|
return false;
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-23 18:46:09 +01:00
|
|
|
bool HexagonEarlyIfConversion::isPredicate(unsigned R) const {
|
|
|
|
const TargetRegisterClass *RC = MRI->getRegClass(R);
|
|
|
|
return RC == &Hexagon::PredRegsRegClass ||
|
|
|
|
RC == &Hexagon::HvxQRRegClass;
|
|
|
|
}
|
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
unsigned HexagonEarlyIfConversion::getCondStoreOpcode(unsigned Opc,
|
|
|
|
bool IfTrue) const {
|
2016-07-26 22:30:30 +02:00
|
|
|
return HII->getCondOpcode(Opc, !IfTrue);
|
2015-10-06 17:49:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonEarlyIfConversion::predicateInstr(MachineBasicBlock *ToB,
|
|
|
|
MachineBasicBlock::iterator At, MachineInstr *MI,
|
|
|
|
unsigned PredR, bool IfTrue) {
|
|
|
|
DebugLoc DL;
|
|
|
|
if (At != ToB->end())
|
|
|
|
DL = At->getDebugLoc();
|
|
|
|
else if (!ToB->empty())
|
|
|
|
DL = ToB->back().getDebugLoc();
|
|
|
|
|
|
|
|
unsigned Opc = MI->getOpcode();
|
|
|
|
|
|
|
|
if (isPredicableStore(MI)) {
|
|
|
|
unsigned COpc = getCondStoreOpcode(Opc, IfTrue);
|
|
|
|
assert(COpc);
|
2016-07-26 22:30:30 +02:00
|
|
|
MachineInstrBuilder MIB = BuildMI(*ToB, At, DL, HII->get(COpc));
|
2016-10-24 23:36:43 +02:00
|
|
|
MachineInstr::mop_iterator MOI = MI->operands_begin();
|
2016-08-01 19:55:48 +02:00
|
|
|
if (HII->isPostIncrement(*MI)) {
|
2017-01-13 10:58:52 +01:00
|
|
|
MIB.add(*MOI);
|
2016-10-24 23:36:43 +02:00
|
|
|
++MOI;
|
2016-07-26 22:30:30 +02:00
|
|
|
}
|
|
|
|
MIB.addReg(PredR);
|
2016-10-24 23:36:43 +02:00
|
|
|
for (const MachineOperand &MO : make_range(MOI, MI->operands_end()))
|
2017-01-13 10:58:52 +01:00
|
|
|
MIB.add(MO);
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
// Set memory references.
|
2018-08-16 23:30:05 +02:00
|
|
|
MIB.cloneMemRefs(*MI);
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
MI->eraseFromParent();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Opc == Hexagon::J2_jump) {
|
|
|
|
MachineBasicBlock *TB = MI->getOperand(0).getMBB();
|
2016-07-26 22:30:30 +02:00
|
|
|
const MCInstrDesc &D = HII->get(IfTrue ? Hexagon::J2_jumpt
|
2015-10-06 17:49:14 +02:00
|
|
|
: Hexagon::J2_jumpf);
|
|
|
|
BuildMI(*ToB, At, DL, D)
|
|
|
|
.addReg(PredR)
|
|
|
|
.addMBB(TB);
|
|
|
|
MI->eraseFromParent();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the offending instruction unconditionally as we are about to
|
|
|
|
// abort.
|
|
|
|
dbgs() << *MI;
|
|
|
|
llvm_unreachable("Unexpected instruction");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Predicate/speculate non-branch instructions from FromB into block ToB.
|
|
|
|
// Leave the branches alone, they will be handled later. Btw, at this point
|
|
|
|
// FromB should have at most one branch, and it should be unconditional.
|
|
|
|
void HexagonEarlyIfConversion::predicateBlockNB(MachineBasicBlock *ToB,
|
|
|
|
MachineBasicBlock::iterator At, MachineBasicBlock *FromB,
|
|
|
|
unsigned PredR, bool IfTrue) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Predicating block " << PrintMB(FromB) << "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
MachineBasicBlock::iterator End = FromB->getFirstTerminator();
|
|
|
|
MachineBasicBlock::iterator I, NextI;
|
|
|
|
|
|
|
|
for (I = FromB->begin(); I != End; I = NextI) {
|
|
|
|
assert(!I->isPHI());
|
|
|
|
NextI = std::next(I);
|
|
|
|
if (isSafeToSpeculate(&*I))
|
|
|
|
ToB->splice(At, FromB, I);
|
|
|
|
else
|
|
|
|
predicateInstr(ToB, At, &*I, PredR, IfTrue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-06 18:24:04 +01:00
|
|
|
unsigned HexagonEarlyIfConversion::buildMux(MachineBasicBlock *B,
|
|
|
|
MachineBasicBlock::iterator At, const TargetRegisterClass *DRC,
|
|
|
|
unsigned PredR, unsigned TR, unsigned TSR, unsigned FR, unsigned FSR) {
|
|
|
|
unsigned Opc = 0;
|
|
|
|
switch (DRC->getID()) {
|
|
|
|
case Hexagon::IntRegsRegClassID:
|
2018-02-20 19:19:17 +01:00
|
|
|
case Hexagon::IntRegsLow8RegClassID:
|
2017-03-06 18:24:04 +01:00
|
|
|
Opc = Hexagon::C2_mux;
|
|
|
|
break;
|
|
|
|
case Hexagon::DoubleRegsRegClassID:
|
2018-02-20 19:19:17 +01:00
|
|
|
case Hexagon::GeneralDoubleLow8RegsRegClassID:
|
2017-03-06 18:24:04 +01:00
|
|
|
Opc = Hexagon::PS_pselect;
|
|
|
|
break;
|
2017-09-15 17:46:05 +02:00
|
|
|
case Hexagon::HvxVRRegClassID:
|
2017-03-06 18:24:04 +01:00
|
|
|
Opc = Hexagon::PS_vselect;
|
|
|
|
break;
|
2017-09-15 17:46:05 +02:00
|
|
|
case Hexagon::HvxWRRegClassID:
|
2017-03-06 18:24:04 +01:00
|
|
|
Opc = Hexagon::PS_wselect;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
llvm_unreachable("unexpected register type");
|
|
|
|
}
|
|
|
|
const MCInstrDesc &D = HII->get(Opc);
|
|
|
|
|
|
|
|
DebugLoc DL = B->findBranchDebugLoc();
|
|
|
|
unsigned MuxR = MRI->createVirtualRegister(DRC);
|
|
|
|
BuildMI(*B, At, DL, D, MuxR)
|
|
|
|
.addReg(PredR)
|
|
|
|
.addReg(TR, 0, TSR)
|
|
|
|
.addReg(FR, 0, FSR);
|
|
|
|
return MuxR;
|
|
|
|
}
|
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
void HexagonEarlyIfConversion::updatePhiNodes(MachineBasicBlock *WhereB,
|
|
|
|
const FlowPattern &FP) {
|
|
|
|
// Visit all PHI nodes in the WhereB block and generate MUX instructions
|
|
|
|
// in the split block. Update the PHI nodes with the values of the MUX.
|
|
|
|
auto NonPHI = WhereB->getFirstNonPHI();
|
|
|
|
for (auto I = WhereB->begin(); I != NonPHI; ++I) {
|
|
|
|
MachineInstr *PN = &*I;
|
|
|
|
// Registers and subregisters corresponding to TrueB, FalseB and SplitB.
|
|
|
|
unsigned TR = 0, TSR = 0, FR = 0, FSR = 0, SR = 0, SSR = 0;
|
|
|
|
for (int i = PN->getNumOperands()-2; i > 0; i -= 2) {
|
|
|
|
const MachineOperand &RO = PN->getOperand(i), &BO = PN->getOperand(i+1);
|
|
|
|
if (BO.getMBB() == FP.SplitB)
|
|
|
|
SR = RO.getReg(), SSR = RO.getSubReg();
|
|
|
|
else if (BO.getMBB() == FP.TrueB)
|
|
|
|
TR = RO.getReg(), TSR = RO.getSubReg();
|
|
|
|
else if (BO.getMBB() == FP.FalseB)
|
|
|
|
FR = RO.getReg(), FSR = RO.getSubReg();
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
PN->RemoveOperand(i+1);
|
|
|
|
PN->RemoveOperand(i);
|
|
|
|
}
|
|
|
|
if (TR == 0)
|
|
|
|
TR = SR, TSR = SSR;
|
|
|
|
else if (FR == 0)
|
|
|
|
FR = SR, FSR = SSR;
|
2017-03-06 18:24:04 +01:00
|
|
|
|
|
|
|
assert(TR || FR);
|
|
|
|
unsigned MuxR = 0, MuxSR = 0;
|
|
|
|
|
|
|
|
if (TR && FR) {
|
|
|
|
unsigned DR = PN->getOperand(0).getReg();
|
|
|
|
const TargetRegisterClass *RC = MRI->getRegClass(DR);
|
|
|
|
MuxR = buildMux(FP.SplitB, FP.SplitB->getFirstTerminator(), RC,
|
|
|
|
FP.PredR, TR, TSR, FR, FSR);
|
|
|
|
} else if (TR) {
|
|
|
|
MuxR = TR;
|
|
|
|
MuxSR = TSR;
|
|
|
|
} else {
|
|
|
|
MuxR = FR;
|
|
|
|
MuxSR = FSR;
|
|
|
|
}
|
|
|
|
|
|
|
|
PN->addOperand(MachineOperand::CreateReg(MuxR, false, false, false, false,
|
|
|
|
false, false, MuxSR));
|
2015-10-06 17:49:14 +02:00
|
|
|
PN->addOperand(MachineOperand::CreateMBB(FP.SplitB));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonEarlyIfConversion::convert(const FlowPattern &FP) {
|
2016-12-14 23:50:46 +01:00
|
|
|
MachineBasicBlock *TSB = nullptr, *FSB = nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
MachineBasicBlock::iterator OldTI = FP.SplitB->getFirstTerminator();
|
|
|
|
assert(OldTI != FP.SplitB->end());
|
|
|
|
DebugLoc DL = OldTI->getDebugLoc();
|
|
|
|
|
|
|
|
if (FP.TrueB) {
|
|
|
|
TSB = *FP.TrueB->succ_begin();
|
|
|
|
predicateBlockNB(FP.SplitB, OldTI, FP.TrueB, FP.PredR, true);
|
|
|
|
}
|
|
|
|
if (FP.FalseB) {
|
|
|
|
FSB = *FP.FalseB->succ_begin();
|
|
|
|
MachineBasicBlock::iterator At = FP.SplitB->getFirstTerminator();
|
|
|
|
predicateBlockNB(FP.SplitB, At, FP.FalseB, FP.PredR, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Regenerate new terminators in the split block and update the successors.
|
|
|
|
// First, remember any information that may be needed later and remove the
|
|
|
|
// existing terminators/successors from the split block.
|
2016-12-14 23:50:46 +01:00
|
|
|
MachineBasicBlock *SSB = nullptr;
|
2015-10-06 17:49:14 +02:00
|
|
|
FP.SplitB->erase(OldTI, FP.SplitB->end());
|
|
|
|
while (FP.SplitB->succ_size() > 0) {
|
|
|
|
MachineBasicBlock *T = *FP.SplitB->succ_begin();
|
|
|
|
// It's possible that the split block had a successor that is not a pre-
|
|
|
|
// dicated block. This could only happen if there was only one block to
|
|
|
|
// be predicated. Example:
|
|
|
|
// split_b:
|
|
|
|
// if (p) jump true_b
|
|
|
|
// jump unrelated2_b
|
|
|
|
// unrelated1_b:
|
|
|
|
// ...
|
|
|
|
// unrelated2_b: ; can have other predecessors, so it's not "false_b"
|
|
|
|
// jump other_b
|
|
|
|
// true_b: ; only reachable from split_b, can be predicated
|
|
|
|
// ...
|
|
|
|
//
|
|
|
|
// Find this successor (SSB) if it exists.
|
|
|
|
if (T != FP.TrueB && T != FP.FalseB) {
|
|
|
|
assert(!SSB);
|
|
|
|
SSB = T;
|
|
|
|
}
|
|
|
|
FP.SplitB->removeSuccessor(FP.SplitB->succ_begin());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert new branches and update the successors of the split block. This
|
|
|
|
// may create unconditional branches to the layout successor, etc., but
|
|
|
|
// that will be cleaned up later. For now, make sure that correct code is
|
|
|
|
// generated.
|
|
|
|
if (FP.JoinB) {
|
|
|
|
assert(!SSB || SSB == FP.JoinB);
|
2016-07-26 22:30:30 +02:00
|
|
|
BuildMI(*FP.SplitB, FP.SplitB->end(), DL, HII->get(Hexagon::J2_jump))
|
2015-10-06 17:49:14 +02:00
|
|
|
.addMBB(FP.JoinB);
|
|
|
|
FP.SplitB->addSuccessor(FP.JoinB);
|
|
|
|
} else {
|
|
|
|
bool HasBranch = false;
|
|
|
|
if (TSB) {
|
2016-07-26 22:30:30 +02:00
|
|
|
BuildMI(*FP.SplitB, FP.SplitB->end(), DL, HII->get(Hexagon::J2_jumpt))
|
2015-10-06 17:49:14 +02:00
|
|
|
.addReg(FP.PredR)
|
|
|
|
.addMBB(TSB);
|
|
|
|
FP.SplitB->addSuccessor(TSB);
|
|
|
|
HasBranch = true;
|
|
|
|
}
|
|
|
|
if (FSB) {
|
2016-07-26 22:30:30 +02:00
|
|
|
const MCInstrDesc &D = HasBranch ? HII->get(Hexagon::J2_jump)
|
|
|
|
: HII->get(Hexagon::J2_jumpf);
|
2015-10-06 17:49:14 +02:00
|
|
|
MachineInstrBuilder MIB = BuildMI(*FP.SplitB, FP.SplitB->end(), DL, D);
|
|
|
|
if (!HasBranch)
|
|
|
|
MIB.addReg(FP.PredR);
|
|
|
|
MIB.addMBB(FSB);
|
|
|
|
FP.SplitB->addSuccessor(FSB);
|
|
|
|
}
|
|
|
|
if (SSB) {
|
|
|
|
// This cannot happen if both TSB and FSB are set. [TF]SB are the
|
|
|
|
// successor blocks of the TrueB and FalseB (or null of the TrueB
|
|
|
|
// or FalseB block is null). SSB is the potential successor block
|
|
|
|
// of the SplitB that is neither TrueB nor FalseB.
|
2016-07-26 22:30:30 +02:00
|
|
|
BuildMI(*FP.SplitB, FP.SplitB->end(), DL, HII->get(Hexagon::J2_jump))
|
2015-10-06 17:49:14 +02:00
|
|
|
.addMBB(SSB);
|
|
|
|
FP.SplitB->addSuccessor(SSB);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// What is left to do is to update the PHI nodes that could have entries
|
|
|
|
// referring to predicated blocks.
|
|
|
|
if (FP.JoinB) {
|
|
|
|
updatePhiNodes(FP.JoinB, FP);
|
|
|
|
} else {
|
|
|
|
if (TSB)
|
|
|
|
updatePhiNodes(TSB, FP);
|
|
|
|
if (FSB)
|
|
|
|
updatePhiNodes(FSB, FP);
|
|
|
|
// Nothing to update in SSB, since SSB's predecessors haven't changed.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonEarlyIfConversion::removeBlock(MachineBasicBlock *B) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Removing block " << PrintMB(B) << "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
// Transfer the immediate dominator information from B to its descendants.
|
|
|
|
MachineDomTreeNode *N = MDT->getNode(B);
|
|
|
|
MachineDomTreeNode *IDN = N->getIDom();
|
|
|
|
if (IDN) {
|
|
|
|
MachineBasicBlock *IDB = IDN->getBlock();
|
2017-07-27 01:20:35 +02:00
|
|
|
|
|
|
|
using GTN = GraphTraits<MachineDomTreeNode *>;
|
|
|
|
using DTNodeVectType = SmallVector<MachineDomTreeNode *, 4>;
|
|
|
|
|
2015-10-06 17:49:14 +02:00
|
|
|
DTNodeVectType Cn(GTN::child_begin(N), GTN::child_end(N));
|
|
|
|
for (DTNodeVectType::iterator I = Cn.begin(), E = Cn.end(); I != E; ++I) {
|
|
|
|
MachineBasicBlock *SB = (*I)->getBlock();
|
|
|
|
MDT->changeImmediateDominator(SB, IDB);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (B->succ_size() > 0)
|
|
|
|
B->removeSuccessor(B->succ_begin());
|
|
|
|
|
|
|
|
for (auto I = B->pred_begin(), E = B->pred_end(); I != E; ++I)
|
2015-12-13 10:26:17 +01:00
|
|
|
(*I)->removeSuccessor(B, true);
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
Deleted.insert(B);
|
|
|
|
MDT->eraseNode(B);
|
Hexagon: Remove implicit ilist iterator conversions, NFC
There are two things out of the ordinary in this commit. First, I made
a loop obviously "infinite" in HexagonInstrInfo.cpp. After checking if
an instruction was at the beginning of a basic block (in which case,
`break`), the loop decremented and checked the iterator for `nullptr` as
the loop condition. This has never been possible (the prev pointers are
always been circular, so even with the weird ilist/iplist
implementation, this isn't been possible), so I removed the condition.
Second, in HexagonAsmPrinter.cpp there was another case of comparing a
`MachineBasicBlock::instr_iterator` against `MachineBasicBlock::end()`
(which returns `MachineBasicBlock::iterator`). While not incorrect,
it's fragile. I switched this to `::instr_end()`.
All that said, no functionality change intended here.
llvm-svn: 250778
2015-10-20 02:46:39 +02:00
|
|
|
MFN->erase(B->getIterator());
|
2015-10-06 17:49:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonEarlyIfConversion::eliminatePhis(MachineBasicBlock *B) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Removing phi nodes from block " << PrintMB(B) << "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
MachineBasicBlock::iterator I, NextI, NonPHI = B->getFirstNonPHI();
|
|
|
|
for (I = B->begin(); I != NonPHI; I = NextI) {
|
|
|
|
NextI = std::next(I);
|
|
|
|
MachineInstr *PN = &*I;
|
|
|
|
assert(PN->getNumOperands() == 3 && "Invalid phi node");
|
|
|
|
MachineOperand &UO = PN->getOperand(1);
|
|
|
|
unsigned UseR = UO.getReg(), UseSR = UO.getSubReg();
|
|
|
|
unsigned DefR = PN->getOperand(0).getReg();
|
|
|
|
unsigned NewR = UseR;
|
|
|
|
if (UseSR) {
|
|
|
|
// MRI.replaceVregUsesWith does not allow to update the subregister,
|
|
|
|
// so instead of doing the use-iteration here, create a copy into a
|
|
|
|
// "non-subregistered" register.
|
2016-06-12 19:30:47 +02:00
|
|
|
const DebugLoc &DL = PN->getDebugLoc();
|
2015-10-06 17:49:14 +02:00
|
|
|
const TargetRegisterClass *RC = MRI->getRegClass(DefR);
|
|
|
|
NewR = MRI->createVirtualRegister(RC);
|
2016-07-26 22:30:30 +02:00
|
|
|
NonPHI = BuildMI(*B, NonPHI, DL, HII->get(TargetOpcode::COPY), NewR)
|
2015-10-06 17:49:14 +02:00
|
|
|
.addReg(UseR, 0, UseSR);
|
|
|
|
}
|
|
|
|
MRI->replaceRegWith(DefR, NewR);
|
|
|
|
B->erase(I);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonEarlyIfConversion::mergeBlocks(MachineBasicBlock *PredB,
|
|
|
|
MachineBasicBlock *SuccB) {
|
2018-05-14 14:53:11 +02:00
|
|
|
LLVM_DEBUG(dbgs() << "Merging blocks " << PrintMB(PredB) << " and "
|
|
|
|
<< PrintMB(SuccB) << "\n");
|
2015-10-06 17:49:14 +02:00
|
|
|
bool TermOk = hasUncondBranch(SuccB);
|
|
|
|
eliminatePhis(SuccB);
|
2016-09-14 22:43:16 +02:00
|
|
|
HII->removeBranch(*PredB);
|
2015-10-06 17:49:14 +02:00
|
|
|
PredB->removeSuccessor(SuccB);
|
|
|
|
PredB->splice(PredB->end(), SuccB, SuccB->begin(), SuccB->end());
|
2018-03-23 19:00:18 +01:00
|
|
|
PredB->transferSuccessorsAndUpdatePHIs(SuccB);
|
2015-10-06 17:49:14 +02:00
|
|
|
removeBlock(SuccB);
|
|
|
|
if (!TermOk)
|
|
|
|
PredB->updateTerminator();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonEarlyIfConversion::simplifyFlowGraph(const FlowPattern &FP) {
|
|
|
|
if (FP.TrueB)
|
|
|
|
removeBlock(FP.TrueB);
|
|
|
|
if (FP.FalseB)
|
|
|
|
removeBlock(FP.FalseB);
|
|
|
|
|
|
|
|
FP.SplitB->updateTerminator();
|
|
|
|
if (FP.SplitB->succ_size() != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
MachineBasicBlock *SB = *FP.SplitB->succ_begin();
|
|
|
|
if (SB->pred_size() != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// By now, the split block has only one successor (SB), and SB has only
|
|
|
|
// one predecessor. We can try to merge them. We will need to update ter-
|
2018-03-23 19:00:18 +01:00
|
|
|
// minators in FP.Split+SB, and that requires working analyzeBranch, which
|
2015-10-06 17:49:14 +02:00
|
|
|
// fails on Hexagon for blocks that have EH_LABELs. However, if SB ends
|
|
|
|
// with an unconditional branch, we won't need to touch the terminators.
|
|
|
|
if (!hasEHLabel(SB) || hasUncondBranch(SB))
|
|
|
|
mergeBlocks(FP.SplitB, SB);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HexagonEarlyIfConversion::runOnMachineFunction(MachineFunction &MF) {
|
2017-12-15 23:22:58 +01:00
|
|
|
if (skipFunction(MF.getFunction()))
|
2016-04-26 21:46:28 +02:00
|
|
|
return false;
|
|
|
|
|
2016-07-26 22:30:30 +02:00
|
|
|
auto &ST = MF.getSubtarget<HexagonSubtarget>();
|
|
|
|
HII = ST.getInstrInfo();
|
2015-10-06 17:49:14 +02:00
|
|
|
TRI = ST.getRegisterInfo();
|
|
|
|
MFN = &MF;
|
|
|
|
MRI = &MF.getRegInfo();
|
|
|
|
MDT = &getAnalysis<MachineDominatorTree>();
|
|
|
|
MLI = &getAnalysis<MachineLoopInfo>();
|
|
|
|
MBPI = EnableHexagonBP ? &getAnalysis<MachineBranchProbabilityInfo>() :
|
|
|
|
nullptr;
|
|
|
|
|
|
|
|
Deleted.clear();
|
|
|
|
bool Changed = false;
|
|
|
|
|
|
|
|
for (MachineLoopInfo::iterator I = MLI->begin(), E = MLI->end(); I != E; ++I)
|
|
|
|
Changed |= visitLoop(*I);
|
2016-12-14 23:50:46 +01:00
|
|
|
Changed |= visitLoop(nullptr);
|
2015-10-06 17:49:14 +02:00
|
|
|
|
|
|
|
return Changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Public Constructor Functions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
FunctionPass *llvm::createHexagonEarlyIfConversion() {
|
|
|
|
return new HexagonEarlyIfConversion();
|
|
|
|
}
|