2012-12-12 05:25:42 +08:00
|
|
|
//===-- SILowerControlFlow.cpp - Use predicates for control flow ----------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08: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
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
2018-05-01 23:54:18 +08:00
|
|
|
/// This pass lowers the pseudo control flow instructions to real
|
2012-12-20 06:10:31 +08:00
|
|
|
/// machine instructions.
|
2012-12-12 05:25:42 +08:00
|
|
|
///
|
2012-12-20 06:10:31 +08:00
|
|
|
/// All control flow is handled using predicated instructions and
|
2012-12-12 05:25:42 +08:00
|
|
|
/// a predicate stack. Each Scalar ALU controls the operations of 64 Vector
|
|
|
|
/// ALUs. The Scalar ALU can update the predicate for any of the Vector ALUs
|
|
|
|
/// by writting to the 64-bit EXEC register (each bit corresponds to a
|
|
|
|
/// single vector ALU). Typically, for predicates, a vector ALU will write
|
|
|
|
/// to its bit of the VCC register (like EXEC VCC is 64-bits, one for each
|
|
|
|
/// Vector ALU) and then the ScalarALU will AND the VCC register with the
|
|
|
|
/// EXEC to update the predicates.
|
|
|
|
///
|
|
|
|
/// For example:
|
2017-11-29 01:15:09 +08:00
|
|
|
/// %vcc = V_CMP_GT_F32 %vgpr1, %vgpr2
|
|
|
|
/// %sgpr0 = SI_IF %vcc
|
|
|
|
/// %vgpr0 = V_ADD_F32 %vgpr0, %vgpr0
|
|
|
|
/// %sgpr0 = SI_ELSE %sgpr0
|
|
|
|
/// %vgpr0 = V_SUB_F32 %vgpr0, %vgpr0
|
|
|
|
/// SI_END_CF %sgpr0
|
2012-12-12 05:25:42 +08:00
|
|
|
///
|
|
|
|
/// becomes:
|
|
|
|
///
|
2017-11-29 01:15:09 +08:00
|
|
|
/// %sgpr0 = S_AND_SAVEEXEC_B64 %vcc // Save and update the exec mask
|
|
|
|
/// %sgpr0 = S_XOR_B64 %sgpr0, %exec // Clear live bits from saved exec mask
|
2012-12-20 06:10:31 +08:00
|
|
|
/// S_CBRANCH_EXECZ label0 // This instruction is an optional
|
2012-12-12 05:25:42 +08:00
|
|
|
/// // optimization which allows us to
|
|
|
|
/// // branch if all the bits of
|
|
|
|
/// // EXEC are zero.
|
2017-11-29 01:15:09 +08:00
|
|
|
/// %vgpr0 = V_ADD_F32 %vgpr0, %vgpr0 // Do the IF block of the branch
|
2012-12-12 05:25:42 +08:00
|
|
|
///
|
|
|
|
/// label0:
|
2017-11-29 01:15:09 +08:00
|
|
|
/// %sgpr0 = S_OR_SAVEEXEC_B64 %exec // Restore the exec mask for the Then block
|
|
|
|
/// %exec = S_XOR_B64 %sgpr0, %exec // Clear live bits from saved exec mask
|
2012-12-12 05:25:42 +08:00
|
|
|
/// S_BRANCH_EXECZ label1 // Use our branch optimization
|
|
|
|
/// // instruction again.
|
2017-11-29 01:15:09 +08:00
|
|
|
/// %vgpr0 = V_SUB_F32 %vgpr0, %vgpr // Do the THEN block
|
2012-12-12 05:25:42 +08:00
|
|
|
/// label1:
|
2017-11-29 01:15:09 +08:00
|
|
|
/// %exec = S_OR_B64 %exec, %sgpr0 // Re-enable saved exec mask bits
|
2012-12-12 05:25:42 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AMDGPU.h"
|
2014-08-05 05:25:23 +08:00
|
|
|
#include "AMDGPUSubtarget.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "SIInstrInfo.h"
|
AMDGPU: Remove #include "MCTargetDesc/AMDGPUMCTargetDesc.h" from common headers
Summary:
MCTargetDesc/AMDGPUMCTargetDesc.h contains enums for all the instuction
and register defintions, which are huge so we only want to include
them where needed.
This will also make it easier if we want to split the R600 and GCN
definitions into separate tablegenerated files.
I was unable to remove AMDGPUMCTargetDesc.h from SIMachineFunctionInfo.h
because it uses some enums from the header to initialize default values
for the SIMachineFunction class, so I ended up having to remove includes of
SIMachineFunctionInfo.h from headers too.
Reviewers: arsenm, nhaehnle
Reviewed By: nhaehnle
Subscribers: MatzeB, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46272
llvm-svn: 332930
2018-05-22 10:03:23 +08:00
|
|
|
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-12-13 10:51:04 +08:00
|
|
|
#include "llvm/CodeGen/LiveIntervals.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
2019-08-01 09:25:27 +08:00
|
|
|
#include "llvm/CodeGen/MachineDominators.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/CodeGen/SlotIndexes.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
2017-01-21 01:52:16 +08:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include <cassert>
|
|
|
|
#include <iterator>
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2016-02-12 10:16:10 +08:00
|
|
|
#define DEBUG_TYPE "si-lower-control-flow"
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-02-12 10:16:10 +08:00
|
|
|
namespace {
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-02-12 10:16:10 +08:00
|
|
|
class SILowerControlFlow : public MachineFunctionPass {
|
2012-12-12 05:25:42 +08:00
|
|
|
private:
|
2017-01-21 01:52:16 +08:00
|
|
|
const SIRegisterInfo *TRI = nullptr;
|
|
|
|
const SIInstrInfo *TII = nullptr;
|
2019-04-27 08:51:18 +08:00
|
|
|
MachineRegisterInfo *MRI = nullptr;
|
2019-08-01 09:25:27 +08:00
|
|
|
LiveIntervals *LIS = nullptr;
|
|
|
|
MachineDominatorTree *DT = nullptr;
|
|
|
|
MachineLoopInfo *MLI = nullptr;
|
|
|
|
|
2012-12-20 06:10:33 +08:00
|
|
|
|
2019-06-17 01:13:09 +08:00
|
|
|
const TargetRegisterClass *BoolRC = nullptr;
|
|
|
|
unsigned AndOpc;
|
|
|
|
unsigned OrOpc;
|
2019-08-01 09:25:27 +08:00
|
|
|
unsigned OrTermOpc;
|
2019-06-17 01:13:09 +08:00
|
|
|
unsigned XorOpc;
|
|
|
|
unsigned MovTermOpc;
|
|
|
|
unsigned Andn2TermOpc;
|
|
|
|
unsigned XorTermrOpc;
|
|
|
|
unsigned OrSaveExecOpc;
|
|
|
|
unsigned Exec;
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
void emitIf(MachineInstr &MI);
|
|
|
|
void emitElse(MachineInstr &MI);
|
|
|
|
void emitIfBreak(MachineInstr &MI);
|
|
|
|
void emitLoop(MachineInstr &MI);
|
|
|
|
void emitEndCf(MachineInstr &MI);
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-11-29 02:58:49 +08:00
|
|
|
void findMaskOperands(MachineInstr &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MachineOperand> &Src) const;
|
|
|
|
|
|
|
|
void combineMasks(MachineInstr &MI);
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
public:
|
2016-02-12 10:16:10 +08:00
|
|
|
static char ID;
|
|
|
|
|
2017-01-21 01:52:16 +08:00
|
|
|
SILowerControlFlow() : MachineFunctionPass(ID) {}
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2014-04-29 15:57:24 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef getPassName() const override {
|
2016-02-12 10:16:10 +08:00
|
|
|
return "SI Lower control flow pseudo instructions";
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
2016-08-23 03:33:16 +08:00
|
|
|
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
2016-09-29 09:44:16 +08:00
|
|
|
// Should preserve the same set that TwoAddressInstructions does.
|
2016-08-23 03:33:16 +08:00
|
|
|
AU.addPreserved<SlotIndexes>();
|
2016-09-29 09:44:16 +08:00
|
|
|
AU.addPreserved<LiveIntervals>();
|
|
|
|
AU.addPreservedID(LiveVariablesID);
|
|
|
|
AU.addPreservedID(MachineLoopInfoID);
|
|
|
|
AU.addPreservedID(MachineDominatorsID);
|
2019-08-01 09:25:27 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
};
|
|
|
|
|
2017-01-21 01:52:16 +08:00
|
|
|
} // end anonymous namespace
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-02-12 10:16:10 +08:00
|
|
|
char SILowerControlFlow::ID = 0;
|
|
|
|
|
|
|
|
INITIALIZE_PASS(SILowerControlFlow, DEBUG_TYPE,
|
2016-08-23 03:33:16 +08:00
|
|
|
"SI lower control flow", false, false)
|
2016-02-12 10:16:10 +08:00
|
|
|
|
2016-09-29 09:44:16 +08:00
|
|
|
static void setImpSCCDefDead(MachineInstr &MI, bool IsDead) {
|
|
|
|
MachineOperand &ImpDefSCC = MI.getOperand(3);
|
|
|
|
assert(ImpDefSCC.getReg() == AMDGPU::SCC && ImpDefSCC.isDef());
|
|
|
|
|
|
|
|
ImpDefSCC.setIsDead(IsDead);
|
|
|
|
}
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
char &llvm::SILowerControlFlowID = SILowerControlFlow::ID;
|
2016-02-12 10:16:10 +08:00
|
|
|
|
2017-10-24 18:27:13 +08:00
|
|
|
static bool isSimpleIf(const MachineInstr &MI, const MachineRegisterInfo *MRI,
|
|
|
|
const SIInstrInfo *TII) {
|
2017-08-04 14:58:42 +08:00
|
|
|
unsigned SaveExecReg = MI.getOperand(0).getReg();
|
|
|
|
auto U = MRI->use_instr_nodbg_begin(SaveExecReg);
|
|
|
|
|
|
|
|
if (U == MRI->use_instr_nodbg_end() ||
|
|
|
|
std::next(U) != MRI->use_instr_nodbg_end() ||
|
|
|
|
U->getOpcode() != AMDGPU::SI_END_CF)
|
|
|
|
return false;
|
|
|
|
|
2017-10-24 18:27:13 +08:00
|
|
|
// Check for SI_KILL_*_TERMINATOR on path from if to endif.
|
2017-08-04 14:58:42 +08:00
|
|
|
// if there is any such terminator simplififcations are not safe.
|
|
|
|
auto SMBB = MI.getParent();
|
|
|
|
auto EMBB = U->getParent();
|
|
|
|
DenseSet<const MachineBasicBlock*> Visited;
|
|
|
|
SmallVector<MachineBasicBlock*, 4> Worklist(SMBB->succ_begin(),
|
|
|
|
SMBB->succ_end());
|
|
|
|
|
|
|
|
while (!Worklist.empty()) {
|
|
|
|
MachineBasicBlock *MBB = Worklist.pop_back_val();
|
|
|
|
|
|
|
|
if (MBB == EMBB || !Visited.insert(MBB).second)
|
|
|
|
continue;
|
|
|
|
for(auto &Term : MBB->terminators())
|
2017-10-24 18:27:13 +08:00
|
|
|
if (TII->isKillTerminator(Term.getOpcode()))
|
2017-08-04 14:58:42 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
Worklist.append(MBB->succ_begin(), MBB->succ_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
void SILowerControlFlow::emitIf(MachineInstr &MI) {
|
|
|
|
MachineBasicBlock &MBB = *MI.getParent();
|
|
|
|
const DebugLoc &DL = MI.getDebugLoc();
|
|
|
|
MachineBasicBlock::iterator I(&MI);
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineOperand &SaveExec = MI.getOperand(0);
|
|
|
|
MachineOperand &Cond = MI.getOperand(1);
|
|
|
|
assert(SaveExec.getSubReg() == AMDGPU::NoSubRegister &&
|
|
|
|
Cond.getSubReg() == AMDGPU::NoSubRegister);
|
2012-12-20 06:10:33 +08:00
|
|
|
|
2019-06-24 23:50:29 +08:00
|
|
|
Register SaveExecReg = SaveExec.getReg();
|
2013-01-19 05:15:50 +08:00
|
|
|
|
2016-09-29 09:44:16 +08:00
|
|
|
MachineOperand &ImpDefSCC = MI.getOperand(4);
|
|
|
|
assert(ImpDefSCC.getReg() == AMDGPU::SCC && ImpDefSCC.isDef());
|
|
|
|
|
2017-07-27 05:29:15 +08:00
|
|
|
// If there is only one use of save exec register and that use is SI_END_CF,
|
|
|
|
// we can optimize SI_IF by returning the full saved exec mask instead of
|
|
|
|
// just cleared bits.
|
2017-10-24 18:27:13 +08:00
|
|
|
bool SimpleIf = isSimpleIf(MI, MRI, TII);
|
2017-07-27 05:29:15 +08:00
|
|
|
|
2016-09-29 09:44:16 +08:00
|
|
|
// Add an implicit def of exec to discourage scheduling VALU after this which
|
|
|
|
// will interfere with trying to form s_and_saveexec_b64 later.
|
2019-06-24 23:50:29 +08:00
|
|
|
Register CopyReg = SimpleIf ? SaveExecReg
|
2019-06-17 01:13:09 +08:00
|
|
|
: MRI->createVirtualRegister(BoolRC);
|
2016-09-29 09:44:16 +08:00
|
|
|
MachineInstr *CopyExec =
|
2016-11-22 09:42:34 +08:00
|
|
|
BuildMI(MBB, I, DL, TII->get(AMDGPU::COPY), CopyReg)
|
2019-06-17 01:13:09 +08:00
|
|
|
.addReg(Exec)
|
|
|
|
.addReg(Exec, RegState::ImplicitDefine);
|
2016-09-29 09:44:16 +08:00
|
|
|
|
2019-06-17 01:13:09 +08:00
|
|
|
unsigned Tmp = MRI->createVirtualRegister(BoolRC);
|
2016-09-29 09:44:16 +08:00
|
|
|
|
|
|
|
MachineInstr *And =
|
2019-06-17 01:13:09 +08:00
|
|
|
BuildMI(MBB, I, DL, TII->get(AndOpc), Tmp)
|
2016-11-22 09:42:34 +08:00
|
|
|
.addReg(CopyReg)
|
2019-03-06 02:38:00 +08:00
|
|
|
.add(Cond);
|
|
|
|
|
2016-09-29 09:44:16 +08:00
|
|
|
setImpSCCDefDead(*And, true);
|
2013-01-19 05:15:50 +08:00
|
|
|
|
2017-07-27 05:29:15 +08:00
|
|
|
MachineInstr *Xor = nullptr;
|
|
|
|
if (!SimpleIf) {
|
|
|
|
Xor =
|
2019-06-17 01:13:09 +08:00
|
|
|
BuildMI(MBB, I, DL, TII->get(XorOpc), SaveExecReg)
|
2017-07-27 05:29:15 +08:00
|
|
|
.addReg(Tmp)
|
|
|
|
.addReg(CopyReg);
|
|
|
|
setImpSCCDefDead(*Xor, ImpDefSCC.isDead());
|
|
|
|
}
|
2016-09-29 09:44:16 +08:00
|
|
|
|
|
|
|
// Use a copy that is a terminator to get correct spill code placement it with
|
|
|
|
// fast regalloc.
|
|
|
|
MachineInstr *SetExec =
|
2019-06-17 01:13:09 +08:00
|
|
|
BuildMI(MBB, I, DL, TII->get(MovTermOpc), Exec)
|
2016-09-29 09:44:16 +08:00
|
|
|
.addReg(Tmp, RegState::Kill);
|
2016-07-13 03:01:23 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
// Insert a pseudo terminator to help keep the verifier happy. This will also
|
|
|
|
// be used later when inserting skips.
|
2017-01-13 17:58:52 +08:00
|
|
|
MachineInstr *NewBr = BuildMI(MBB, I, DL, TII->get(AMDGPU::SI_MASK_BRANCH))
|
|
|
|
.add(MI.getOperand(2));
|
2013-01-19 05:15:50 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
if (!LIS) {
|
|
|
|
MI.eraseFromParent();
|
|
|
|
return;
|
|
|
|
}
|
2016-07-13 03:01:23 +08:00
|
|
|
|
2016-09-29 09:44:16 +08:00
|
|
|
LIS->InsertMachineInstrInMaps(*CopyExec);
|
|
|
|
|
|
|
|
// Replace with and so we don't need to fix the live interval for condition
|
|
|
|
// register.
|
|
|
|
LIS->ReplaceMachineInstrInMaps(MI, *And);
|
2013-01-19 05:15:50 +08:00
|
|
|
|
2017-07-27 05:29:15 +08:00
|
|
|
if (!SimpleIf)
|
|
|
|
LIS->InsertMachineInstrInMaps(*Xor);
|
2016-09-29 09:44:16 +08:00
|
|
|
LIS->InsertMachineInstrInMaps(*SetExec);
|
2016-08-23 03:33:16 +08:00
|
|
|
LIS->InsertMachineInstrInMaps(*NewBr);
|
2016-07-13 03:01:23 +08:00
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
LIS->removeAllRegUnitsForPhysReg(Exec);
|
2016-08-23 03:33:16 +08:00
|
|
|
MI.eraseFromParent();
|
2016-07-13 03:01:23 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
// FIXME: Is there a better way of adjusting the liveness? It shouldn't be
|
|
|
|
// hard to add another def here but I'm not sure how to correctly update the
|
|
|
|
// valno.
|
|
|
|
LIS->removeInterval(SaveExecReg);
|
|
|
|
LIS->createAndComputeVirtRegInterval(SaveExecReg);
|
2016-09-29 09:44:16 +08:00
|
|
|
LIS->createAndComputeVirtRegInterval(Tmp);
|
2017-07-27 05:29:15 +08:00
|
|
|
if (!SimpleIf)
|
|
|
|
LIS->createAndComputeVirtRegInterval(CopyReg);
|
2013-01-19 05:15:50 +08:00
|
|
|
}
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
void SILowerControlFlow::emitElse(MachineInstr &MI) {
|
2012-12-20 06:10:31 +08:00
|
|
|
MachineBasicBlock &MBB = *MI.getParent();
|
2016-08-23 03:33:16 +08:00
|
|
|
const DebugLoc &DL = MI.getDebugLoc();
|
2012-12-20 06:10:31 +08:00
|
|
|
|
2019-06-24 23:50:29 +08:00
|
|
|
Register DstReg = MI.getOperand(0).getReg();
|
2016-08-23 03:33:16 +08:00
|
|
|
assert(MI.getOperand(0).getSubReg() == AMDGPU::NoSubRegister);
|
2012-12-20 06:10:31 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
bool ExecModified = MI.getOperand(3).getImm() != 0;
|
|
|
|
MachineBasicBlock::iterator Start = MBB.begin();
|
2012-12-20 06:10:31 +08:00
|
|
|
|
2016-09-29 09:44:16 +08:00
|
|
|
// We are running before TwoAddressInstructions, and si_else's operands are
|
|
|
|
// tied. In order to correctly tie the registers, split this into a copy of
|
|
|
|
// the src like it does.
|
2019-06-24 23:50:29 +08:00
|
|
|
Register CopyReg = MRI->createVirtualRegister(BoolRC);
|
2017-01-20 05:26:22 +08:00
|
|
|
MachineInstr *CopyExec =
|
|
|
|
BuildMI(MBB, Start, DL, TII->get(AMDGPU::COPY), CopyReg)
|
2017-01-13 17:58:52 +08:00
|
|
|
.add(MI.getOperand(1)); // Saved EXEC
|
2016-09-29 09:44:16 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
// This must be inserted before phis and any spill code inserted before the
|
|
|
|
// else.
|
2019-06-24 23:50:29 +08:00
|
|
|
Register SaveReg = ExecModified ?
|
2019-06-17 01:13:09 +08:00
|
|
|
MRI->createVirtualRegister(BoolRC) : DstReg;
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineInstr *OrSaveExec =
|
2019-06-17 01:13:09 +08:00
|
|
|
BuildMI(MBB, Start, DL, TII->get(OrSaveExecOpc), SaveReg)
|
2016-11-22 09:42:34 +08:00
|
|
|
.addReg(CopyReg);
|
2016-09-29 09:44:16 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineBasicBlock *DestBB = MI.getOperand(2).getMBB();
|
2016-08-11 03:11:42 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineBasicBlock::iterator ElsePt(MI);
|
2012-12-20 06:10:33 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
if (ExecModified) {
|
|
|
|
MachineInstr *And =
|
2019-06-17 01:13:09 +08:00
|
|
|
BuildMI(MBB, ElsePt, DL, TII->get(AndOpc), DstReg)
|
|
|
|
.addReg(Exec)
|
2016-11-22 09:42:34 +08:00
|
|
|
.addReg(SaveReg);
|
2016-06-23 04:15:28 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
if (LIS)
|
|
|
|
LIS->InsertMachineInstrInMaps(*And);
|
2016-03-22 04:28:33 +08:00
|
|
|
}
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineInstr *Xor =
|
2019-06-17 01:13:09 +08:00
|
|
|
BuildMI(MBB, ElsePt, DL, TII->get(XorTermrOpc), Exec)
|
|
|
|
.addReg(Exec)
|
2016-08-23 03:33:16 +08:00
|
|
|
.addReg(DstReg);
|
2012-12-20 06:10:33 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineInstr *Branch =
|
2016-09-29 09:44:16 +08:00
|
|
|
BuildMI(MBB, ElsePt, DL, TII->get(AMDGPU::SI_MASK_BRANCH))
|
2016-08-27 08:42:21 +08:00
|
|
|
.addMBB(DestBB);
|
2016-08-23 03:33:16 +08:00
|
|
|
|
|
|
|
if (!LIS) {
|
|
|
|
MI.eraseFromParent();
|
|
|
|
return;
|
|
|
|
}
|
2016-06-23 04:15:28 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
LIS->RemoveMachineInstrFromMaps(MI);
|
2012-12-20 06:10:31 +08:00
|
|
|
MI.eraseFromParent();
|
|
|
|
|
2017-01-20 05:26:22 +08:00
|
|
|
LIS->InsertMachineInstrInMaps(*CopyExec);
|
2016-08-23 03:33:16 +08:00
|
|
|
LIS->InsertMachineInstrInMaps(*OrSaveExec);
|
2016-07-10 01:18:39 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
LIS->InsertMachineInstrInMaps(*Xor);
|
|
|
|
LIS->InsertMachineInstrInMaps(*Branch);
|
2016-07-10 01:18:39 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
// src reg is tied to dst reg.
|
|
|
|
LIS->removeInterval(DstReg);
|
|
|
|
LIS->createAndComputeVirtRegInterval(DstReg);
|
2016-11-22 09:42:34 +08:00
|
|
|
LIS->createAndComputeVirtRegInterval(CopyReg);
|
|
|
|
if (ExecModified)
|
|
|
|
LIS->createAndComputeVirtRegInterval(SaveReg);
|
2016-07-10 01:18:39 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
// Let this be recomputed.
|
2019-08-01 09:25:27 +08:00
|
|
|
LIS->removeAllRegUnitsForPhysReg(Exec);
|
2016-07-10 01:18:39 +08:00
|
|
|
}
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
void SILowerControlFlow::emitIfBreak(MachineInstr &MI) {
|
2018-05-25 15:55:04 +08:00
|
|
|
MachineBasicBlock &MBB = *MI.getParent();
|
|
|
|
const DebugLoc &DL = MI.getDebugLoc();
|
|
|
|
auto Dst = MI.getOperand(0).getReg();
|
|
|
|
|
|
|
|
// Skip ANDing with exec if the break condition is already masked by exec
|
|
|
|
// because it is a V_CMP in the same basic block. (We know the break
|
|
|
|
// condition operand was an i1 in IR, so if it is a VALU instruction it must
|
|
|
|
// be one with a carry-out.)
|
|
|
|
bool SkipAnding = false;
|
|
|
|
if (MI.getOperand(1).isReg()) {
|
|
|
|
if (MachineInstr *Def = MRI->getUniqueVRegDef(MI.getOperand(1).getReg())) {
|
|
|
|
SkipAnding = Def->getParent() == MI.getParent()
|
|
|
|
&& SIInstrInfo::isVALU(*Def);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// AND the break condition operand with exec, then OR that into the "loop
|
|
|
|
// exit" mask.
|
|
|
|
MachineInstr *And = nullptr, *Or = nullptr;
|
|
|
|
if (!SkipAnding) {
|
2019-06-17 01:13:09 +08:00
|
|
|
And = BuildMI(MBB, &MI, DL, TII->get(AndOpc), Dst)
|
|
|
|
.addReg(Exec)
|
2018-05-25 15:55:04 +08:00
|
|
|
.add(MI.getOperand(1));
|
2019-06-17 01:13:09 +08:00
|
|
|
Or = BuildMI(MBB, &MI, DL, TII->get(OrOpc), Dst)
|
2018-05-25 15:55:04 +08:00
|
|
|
.addReg(Dst)
|
|
|
|
.add(MI.getOperand(2));
|
|
|
|
} else
|
2019-06-17 01:13:09 +08:00
|
|
|
Or = BuildMI(MBB, &MI, DL, TII->get(OrOpc), Dst)
|
2018-05-25 15:55:04 +08:00
|
|
|
.add(MI.getOperand(1))
|
|
|
|
.add(MI.getOperand(2));
|
|
|
|
|
|
|
|
if (LIS) {
|
|
|
|
if (And)
|
|
|
|
LIS->InsertMachineInstrInMaps(*And);
|
|
|
|
LIS->ReplaceMachineInstrInMaps(MI, *Or);
|
|
|
|
}
|
|
|
|
|
|
|
|
MI.eraseFromParent();
|
2016-08-23 03:33:16 +08:00
|
|
|
}
|
2012-12-20 06:10:31 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
void SILowerControlFlow::emitLoop(MachineInstr &MI) {
|
2012-12-20 06:10:31 +08:00
|
|
|
MachineBasicBlock &MBB = *MI.getParent();
|
2016-08-23 03:33:16 +08:00
|
|
|
const DebugLoc &DL = MI.getDebugLoc();
|
2012-12-20 06:10:31 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineInstr *AndN2 =
|
2019-06-17 01:13:09 +08:00
|
|
|
BuildMI(MBB, &MI, DL, TII->get(Andn2TermOpc), Exec)
|
|
|
|
.addReg(Exec)
|
2017-01-13 17:58:52 +08:00
|
|
|
.add(MI.getOperand(0));
|
2012-12-20 06:10:31 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineInstr *Branch =
|
2017-01-13 17:58:52 +08:00
|
|
|
BuildMI(MBB, &MI, DL, TII->get(AMDGPU::S_CBRANCH_EXECNZ))
|
|
|
|
.add(MI.getOperand(1));
|
2012-12-20 06:10:31 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
if (LIS) {
|
|
|
|
LIS->ReplaceMachineInstrInMaps(MI, *AndN2);
|
|
|
|
LIS->InsertMachineInstrInMaps(*Branch);
|
|
|
|
}
|
2012-12-20 06:10:31 +08:00
|
|
|
|
|
|
|
MI.eraseFromParent();
|
|
|
|
}
|
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
// Insert \p Inst (which modifies exec) at \p InsPt in \p MBB, such that \p MBB
|
|
|
|
// is split as necessary to keep the exec modification in its own block.
|
|
|
|
static MachineBasicBlock *insertInstWithExecFallthrough(MachineBasicBlock &MBB,
|
|
|
|
MachineInstr &MI,
|
|
|
|
MachineInstr *NewMI,
|
|
|
|
MachineDominatorTree *DT,
|
|
|
|
LiveIntervals *LIS,
|
|
|
|
MachineLoopInfo *MLI) {
|
|
|
|
assert(NewMI->isTerminator());
|
|
|
|
|
|
|
|
MachineBasicBlock::iterator InsPt = MI.getIterator();
|
|
|
|
if (std::next(MI.getIterator()) == MBB.end()) {
|
|
|
|
// Don't bother with a new block.
|
|
|
|
MBB.insert(InsPt, NewMI);
|
|
|
|
if (LIS)
|
|
|
|
LIS->ReplaceMachineInstrInMaps(MI, *NewMI);
|
|
|
|
MI.eraseFromParent();
|
|
|
|
return &MBB;
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineFunction *MF = MBB.getParent();
|
|
|
|
MachineBasicBlock *SplitMBB
|
|
|
|
= MF->CreateMachineBasicBlock(MBB.getBasicBlock());
|
|
|
|
|
|
|
|
MF->insert(++MachineFunction::iterator(MBB), SplitMBB);
|
|
|
|
|
|
|
|
// FIXME: This is working around a MachineDominatorTree API defect.
|
|
|
|
//
|
|
|
|
// If a previous pass split a critical edge, it may not have been applied to
|
|
|
|
// the DomTree yet. applySplitCriticalEdges is lazily applied, and inspects
|
|
|
|
// the CFG of the given block. Make sure to call a dominator tree method that
|
|
|
|
// will flush this cache before touching the successors of the block.
|
|
|
|
MachineDomTreeNode *NodeMBB = nullptr;
|
|
|
|
if (DT)
|
|
|
|
NodeMBB = DT->getNode(&MBB);
|
|
|
|
|
|
|
|
// Move everything to the new block, except the end_cf pseudo.
|
|
|
|
SplitMBB->splice(SplitMBB->begin(), &MBB, MBB.begin(), MBB.end());
|
|
|
|
|
|
|
|
SplitMBB->transferSuccessorsAndUpdatePHIs(&MBB);
|
|
|
|
MBB.addSuccessor(SplitMBB, BranchProbability::getOne());
|
|
|
|
|
|
|
|
MBB.insert(MBB.end(), NewMI);
|
|
|
|
|
|
|
|
if (DT) {
|
|
|
|
std::vector<MachineDomTreeNode *> Children = NodeMBB->getChildren();
|
|
|
|
DT->addNewBlock(SplitMBB, &MBB);
|
|
|
|
|
|
|
|
// Reparent all of the children to the new block body.
|
|
|
|
auto *SplitNode = DT->getNode(SplitMBB);
|
|
|
|
for (auto *Child : Children)
|
|
|
|
DT->changeImmediateDominator(Child, SplitNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MLI) {
|
|
|
|
if (MachineLoop *Loop = MLI->getLoopFor(&MBB))
|
|
|
|
Loop->addBasicBlockToLoop(SplitMBB, MLI->getBase());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LIS) {
|
|
|
|
LIS->insertMBBInMaps(SplitMBB);
|
|
|
|
LIS->ReplaceMachineInstrInMaps(MI, *NewMI);
|
|
|
|
}
|
|
|
|
|
|
|
|
// All live-ins are forwarded.
|
|
|
|
for (auto &LiveIn : MBB.liveins())
|
|
|
|
SplitMBB->addLiveIn(LiveIn);
|
|
|
|
|
|
|
|
MI.eraseFromParent();
|
|
|
|
return SplitMBB;
|
|
|
|
}
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
void SILowerControlFlow::emitEndCf(MachineInstr &MI) {
|
2013-01-19 05:15:50 +08:00
|
|
|
MachineBasicBlock &MBB = *MI.getParent();
|
2016-08-23 03:33:16 +08:00
|
|
|
const DebugLoc &DL = MI.getDebugLoc();
|
2013-01-19 05:15:50 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
MachineBasicBlock::iterator InsPt = MBB.begin();
|
2016-07-13 05:41:32 +08:00
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
// First, move the instruction. It's unnecessarily difficult to update
|
|
|
|
// LiveIntervals when there's a change in control flow, so move the
|
|
|
|
// instruction before changing the blocks.
|
|
|
|
MBB.splice(InsPt, &MBB, MI.getIterator());
|
2016-08-23 03:33:16 +08:00
|
|
|
if (LIS)
|
2019-08-01 09:25:27 +08:00
|
|
|
LIS->handleMove(MI);
|
2016-07-13 05:41:32 +08:00
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
MachineFunction *MF = MBB.getParent();
|
2016-07-13 05:41:32 +08:00
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
// Create instruction without inserting it yet.
|
|
|
|
MachineInstr *NewMI
|
|
|
|
= BuildMI(*MF, DL, TII->get(OrTermOpc), Exec)
|
|
|
|
.addReg(Exec)
|
|
|
|
.add(MI.getOperand(0));
|
|
|
|
insertInstWithExecFallthrough(MBB, MI, NewMI, DT, LIS, MLI);
|
2016-07-13 05:41:32 +08:00
|
|
|
}
|
|
|
|
|
2016-11-29 02:58:49 +08:00
|
|
|
// Returns replace operands for a logical operation, either single result
|
|
|
|
// for exec or two operands if source was another equivalent operation.
|
|
|
|
void SILowerControlFlow::findMaskOperands(MachineInstr &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MachineOperand> &Src) const {
|
|
|
|
MachineOperand &Op = MI.getOperand(OpNo);
|
2019-08-02 07:27:28 +08:00
|
|
|
if (!Op.isReg() || !Register::isVirtualRegister(Op.getReg())) {
|
2016-11-29 02:58:49 +08:00
|
|
|
Src.push_back(Op);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineInstr *Def = MRI->getUniqueVRegDef(Op.getReg());
|
|
|
|
if (!Def || Def->getParent() != MI.getParent() ||
|
|
|
|
!(Def->isFullCopy() || (Def->getOpcode() == MI.getOpcode())))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Make sure we do not modify exec between def and use.
|
|
|
|
// A copy with implcitly defined exec inserted earlier is an exclusion, it
|
|
|
|
// does not really modify exec.
|
|
|
|
for (auto I = Def->getIterator(); I != MI.getIterator(); ++I)
|
2019-08-01 09:25:27 +08:00
|
|
|
if (I->modifiesRegister(Exec, TRI) &&
|
2019-06-17 01:13:09 +08:00
|
|
|
!(I->isCopy() && I->getOperand(0).getReg() != Exec))
|
2016-11-29 02:58:49 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (const auto &SrcOp : Def->explicit_operands())
|
2018-06-12 08:41:26 +08:00
|
|
|
if (SrcOp.isReg() && SrcOp.isUse() &&
|
2019-08-02 07:27:28 +08:00
|
|
|
(Register::isVirtualRegister(SrcOp.getReg()) || SrcOp.getReg() == Exec))
|
2016-11-29 02:58:49 +08:00
|
|
|
Src.push_back(SrcOp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search and combine pairs of equivalent instructions, like
|
|
|
|
// S_AND_B64 x, (S_AND_B64 x, y) => S_AND_B64 x, y
|
|
|
|
// S_OR_B64 x, (S_OR_B64 x, y) => S_OR_B64 x, y
|
|
|
|
// One of the operands is exec mask.
|
|
|
|
void SILowerControlFlow::combineMasks(MachineInstr &MI) {
|
|
|
|
assert(MI.getNumExplicitOperands() == 3);
|
|
|
|
SmallVector<MachineOperand, 4> Ops;
|
|
|
|
unsigned OpToReplace = 1;
|
|
|
|
findMaskOperands(MI, 1, Ops);
|
|
|
|
if (Ops.size() == 1) OpToReplace = 2; // First operand can be exec or its copy
|
|
|
|
findMaskOperands(MI, 2, Ops);
|
|
|
|
if (Ops.size() != 3) return;
|
|
|
|
|
|
|
|
unsigned UniqueOpndIdx;
|
|
|
|
if (Ops[0].isIdenticalTo(Ops[1])) UniqueOpndIdx = 2;
|
|
|
|
else if (Ops[0].isIdenticalTo(Ops[2])) UniqueOpndIdx = 1;
|
|
|
|
else if (Ops[1].isIdenticalTo(Ops[2])) UniqueOpndIdx = 1;
|
|
|
|
else return;
|
|
|
|
|
|
|
|
unsigned Reg = MI.getOperand(OpToReplace).getReg();
|
|
|
|
MI.RemoveOperand(OpToReplace);
|
|
|
|
MI.addOperand(Ops[UniqueOpndIdx]);
|
|
|
|
if (MRI->use_empty(Reg))
|
|
|
|
MRI->getUniqueVRegDef(Reg)->eraseFromParent();
|
|
|
|
}
|
|
|
|
|
2016-02-12 10:16:10 +08:00
|
|
|
bool SILowerControlFlow::runOnMachineFunction(MachineFunction &MF) {
|
2018-07-12 04:59:01 +08:00
|
|
|
const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
|
2016-06-24 14:30:11 +08:00
|
|
|
TII = ST.getInstrInfo();
|
|
|
|
TRI = &TII->getRegisterInfo();
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
// This doesn't actually need LiveIntervals, but we can preserve them.
|
|
|
|
LIS = getAnalysisIfAvailable<LiveIntervals>();
|
2019-08-01 09:25:27 +08:00
|
|
|
DT = getAnalysisIfAvailable<MachineDominatorTree>();
|
|
|
|
MLI = getAnalysisIfAvailable<MachineLoopInfo>();
|
|
|
|
|
2016-09-29 09:44:16 +08:00
|
|
|
MRI = &MF.getRegInfo();
|
2019-06-17 01:13:09 +08:00
|
|
|
BoolRC = TRI->getBoolRC();
|
|
|
|
|
|
|
|
if (ST.isWave32()) {
|
|
|
|
AndOpc = AMDGPU::S_AND_B32;
|
|
|
|
OrOpc = AMDGPU::S_OR_B32;
|
2019-08-01 09:25:27 +08:00
|
|
|
OrTermOpc = AMDGPU::S_OR_B32_term;
|
2019-06-17 01:13:09 +08:00
|
|
|
XorOpc = AMDGPU::S_XOR_B32;
|
|
|
|
MovTermOpc = AMDGPU::S_MOV_B32_term;
|
|
|
|
Andn2TermOpc = AMDGPU::S_ANDN2_B32_term;
|
|
|
|
XorTermrOpc = AMDGPU::S_XOR_B32_term;
|
|
|
|
OrSaveExecOpc = AMDGPU::S_OR_SAVEEXEC_B32;
|
|
|
|
Exec = AMDGPU::EXEC_LO;
|
|
|
|
} else {
|
|
|
|
AndOpc = AMDGPU::S_AND_B64;
|
|
|
|
OrOpc = AMDGPU::S_OR_B64;
|
2019-08-01 09:25:27 +08:00
|
|
|
OrTermOpc = AMDGPU::S_OR_B64_term;
|
2019-06-17 01:13:09 +08:00
|
|
|
XorOpc = AMDGPU::S_XOR_B64;
|
|
|
|
MovTermOpc = AMDGPU::S_MOV_B64_term;
|
|
|
|
Andn2TermOpc = AMDGPU::S_ANDN2_B64_term;
|
|
|
|
XorTermrOpc = AMDGPU::S_XOR_B64_term;
|
|
|
|
OrSaveExecOpc = AMDGPU::S_OR_SAVEEXEC_B64;
|
|
|
|
Exec = AMDGPU::EXEC;
|
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-06-23 04:15:28 +08:00
|
|
|
MachineFunction::iterator NextBB;
|
|
|
|
for (MachineFunction::iterator BI = MF.begin(), BE = MF.end();
|
|
|
|
BI != BE; BI = NextBB) {
|
|
|
|
NextBB = std::next(BI);
|
2019-08-01 09:25:27 +08:00
|
|
|
MachineBasicBlock *MBB = &*BI;
|
2016-06-23 04:15:28 +08:00
|
|
|
|
2016-11-29 02:58:49 +08:00
|
|
|
MachineBasicBlock::iterator I, Next, Last;
|
2016-03-22 04:28:33 +08:00
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
for (I = MBB->begin(), Last = MBB->end(); I != MBB->end(); I = Next) {
|
2014-03-02 20:27:27 +08:00
|
|
|
Next = std::next(I);
|
2012-12-12 05:25:42 +08:00
|
|
|
MachineInstr &MI = *I;
|
2014-02-11 00:58:30 +08:00
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
switch (MI.getOpcode()) {
|
2016-08-23 03:33:16 +08:00
|
|
|
case AMDGPU::SI_IF:
|
|
|
|
emitIf(MI);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AMDGPU::SI_ELSE:
|
|
|
|
emitElse(MI);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AMDGPU::SI_IF_BREAK:
|
|
|
|
emitIfBreak(MI);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AMDGPU::SI_LOOP:
|
|
|
|
emitLoop(MI);
|
|
|
|
break;
|
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
case AMDGPU::SI_END_CF: {
|
|
|
|
MachineInstr *NextMI = nullptr;
|
|
|
|
|
|
|
|
if (Next != MBB->end())
|
|
|
|
NextMI = &*Next;
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
emitEndCf(MI);
|
2019-04-27 08:51:18 +08:00
|
|
|
|
2019-08-01 09:25:27 +08:00
|
|
|
if (NextMI) {
|
|
|
|
MBB = NextMI->getParent();
|
|
|
|
Next = NextMI->getIterator();
|
|
|
|
Last = MBB->end();
|
|
|
|
}
|
|
|
|
|
|
|
|
NextBB = std::next(MBB->getIterator());
|
|
|
|
BE = MF.end();
|
|
|
|
break;
|
|
|
|
}
|
2016-11-29 02:58:49 +08:00
|
|
|
case AMDGPU::S_AND_B64:
|
|
|
|
case AMDGPU::S_OR_B64:
|
2019-06-17 01:13:09 +08:00
|
|
|
case AMDGPU::S_AND_B32:
|
|
|
|
case AMDGPU::S_OR_B32:
|
2016-11-29 02:58:49 +08:00
|
|
|
// Cleanup bit manipulations on exec mask
|
|
|
|
combineMasks(MI);
|
|
|
|
Last = I;
|
|
|
|
continue;
|
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
default:
|
2016-11-29 02:58:49 +08:00
|
|
|
Last = I;
|
|
|
|
continue;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
2016-11-29 02:58:49 +08:00
|
|
|
|
|
|
|
// Replay newly inserted code to combine masks
|
2019-08-01 09:25:27 +08:00
|
|
|
Next = (Last == MBB->end()) ? MBB->begin() : Last;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
}
|
2016-08-23 03:33:16 +08:00
|
|
|
|
2012-12-20 06:10:31 +08:00
|
|
|
return true;
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|