[llvm] Move SI Lower Control Flow Up (PR #159557)
Patrick Simmons via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 10:14:04 PST 2025
================
@@ -0,0 +1,261 @@
+#pragma once
+
+#include "GCNSubtarget.h"
+#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/Support/ErrorHandling.h"
+
+#include "SIInstrInfo.h"
+
+#include <cassert>
+#include <unordered_set>
+
+using namespace llvm;
+
+using std::unordered_set;
+using std::vector;
+
+static inline MachineInstr &getBranchWithDest(MachineBasicBlock &BranchingMBB,
+ MachineBasicBlock &DestMBB) {
+ auto &TII =
+ *BranchingMBB.getParent()->getSubtarget<GCNSubtarget>().getInstrInfo();
+ for (MachineInstr &BranchMI : reverse(BranchingMBB.instrs()))
+ if (BranchMI.isBranch() && TII.getBranchDestBlock(BranchMI) == &DestMBB)
+ return BranchMI;
+
+ llvm_unreachable("Don't call this if there's no branch to the destination.");
+}
+
+static inline void moveInsBeforePhis(MachineInstr &MI) {
----------------
linuxrocks123 wrote:
EXEC-modifying instructions must happen prior to PHIs in block X. This function accomplishes that by moving them to the tails of all of the predecessors of X.
https://github.com/llvm/llvm-project/pull/159557
More information about the llvm-commits
mailing list