Skip to content

Commit

Permalink
[VENTUS][fix] Fix insert join instruction bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoujingya committed Sep 13, 2023
1 parent 0e5eef6 commit 4232ad0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions llvm/lib/Target/RISCV/VentusInsertJoinToVBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
// WRANING: Do not use -O(1|2|3) optimization option
//===----------------------------------------------------------------------===//

#include "MCTargetDesc/RISCVMCTargetDesc.h"
#include "RISCV.h"
#include "RISCVInstrInfo.h"
#include "RISCVTargetMachine.h"
Expand Down Expand Up @@ -121,12 +122,16 @@ bool VentusInsertJoinToVBranch::runOnMachineFunction(MachineFunction &MF) {
// FIXME: There is something wrong when add this operand.
// VBranch->addOperand(MachineOperand::CreateReg(
// RISCV::RPC, false /* isDef */, true /* isImp */));

auto InsertPosition = PostIDomBB->begin();
if (!JoinedBB.contains(PostIDomBB)) {
IsChanged = true;
JoinedBB.insert(PostIDomBB);
BuildMI(*PostIDomBB, PostIDomBB->begin(), DebugLoc(),
TII->get(RISCV::JOIN))
// Insert join instruction after last vmv.v instruction
for (auto &MI : *PostIDomBB) {
if (MI.getOpcode() == RISCV::VMV_V_X)
InsertPosition = MI.getIterator();
}
BuildMI(*PostIDomBB, InsertPosition, DebugLoc(), TII->get(RISCV::JOIN))
.addReg(RISCV::X0)
.addReg(RISCV::X0)
.addImm(0);
Expand Down

0 comments on commit 4232ad0

Please sign in to comment.