From f781479b526e960b840836b46b17c66b6469aa05 Mon Sep 17 00:00:00 2001 From: qinfan Date: Fri, 29 Mar 2024 16:15:12 +0800 Subject: [PATCH] [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. --- .../lib/Target/RISCV/VentusInsertJoinToVBranch.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/RISCV/VentusInsertJoinToVBranch.cpp b/llvm/lib/Target/RISCV/VentusInsertJoinToVBranch.cpp index f6664c43cbf5..ef5c6a8a4ce5 100644 --- a/llvm/lib/Target/RISCV/VentusInsertJoinToVBranch.cpp +++ b/llvm/lib/Target/RISCV/VentusInsertJoinToVBranch.cpp @@ -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}); }