1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[Hexagon] Factor out some common code in HexagonEarlyIfConv.cpp, NFC

llvm-svn: 299367
This commit is contained in:
Krzysztof Parzyszek 2017-04-03 17:26:40 +00:00
parent 4e644f852f
commit b70a46e6dd

View File

@ -537,18 +537,16 @@ bool HexagonEarlyIfConversion::isProfitable(const FlowPattern &FP) const {
// 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.
unsigned TS = 0, FS = 0, Spare = 0;
if (FP.TrueB) {
TS = std::distance(FP.TrueB->begin(), FP.TrueB->getFirstTerminator());
if (TS < HEXAGON_PACKET_SIZE)
Spare += HEXAGON_PACKET_SIZE-TS;
}
if (FP.FalseB) {
FS = std::distance(FP.FalseB->begin(), FP.FalseB->getFirstTerminator());
if (FS < HEXAGON_PACKET_SIZE)
Spare += HEXAGON_PACKET_SIZE-FS;
}
unsigned TotalIn = TS+FS;
auto TotalCount = [] (const MachineBasicBlock *B, unsigned &Spare) {
if (!B)
return 0u;
unsigned T = std::distance(B->begin(), B->getFirstTerminator());
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);
DEBUG(dbgs() << "Total number of instructions to be predicated/speculated: "
<< TotalIn << ", spare room: " << Spare << "\n");
if (TotalIn >= SizeLimit+Spare)