[VENTUS][RISCV] Fix move instructions after JOIN move forward bug

1. If the move instruction needs to be moved forward, it will only be inserted after the last corresponding move instruction in the predecessor basic block.
2. The first instruction of the predecessor is also counted as a possible insertion point.
This commit is contained in:
qinfan 2024-03-29 16:15:12 +08:00
parent 078bb26e2e
commit f781479b52
1 changed files with 13 additions and 1 deletions

View File

@ -236,8 +236,20 @@ bool VentusInsertJoinToVBranch::checkJoinMBB(MachineBasicBlock &MBB) const {
if (&MI1 == &Def)
Insert = MI1.getIterator();
}
if (Insert != Pre->begin()) {
if (Insert != Pre->begin() || Pre->begin() == &Def) {
// Last instruction define in Pre MBB
bool IsInsert = false;
for(auto Pair : MBBMaybeInsertedInstr) {
if (Pair.first == Pre) {
IsInsert = true;
break;
}
}
// Only last MI in Pre need to insert
if (IsInsert)
continue;
NeedToBeInsertMBBNum++;
MBBMaybeInsertedInstr.push_back({Pre, Insert});
}