[llvm] [AArch64][SME] Fixup ABI routine insertion points to avoid clobbering NZCV (PR #161353)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 02:42:28 PDT 2025
================
@@ -476,6 +491,41 @@ MachineSMEABI::assignBundleZAStates(const EdgeBundles &Bundles,
return BundleStates;
}
+std::pair<MachineBasicBlock::iterator, LiveRegs>
+MachineSMEABI::findStateChangeInsertionPoint(
+ MachineBasicBlock &MBB, const BlockInfo &Block,
+ SmallVectorImpl<InstInfo>::const_iterator Inst) {
+ LiveRegs PhysLiveRegs;
+ MachineBasicBlock::iterator InsertPt;
+ if (Inst != Block.Insts.end()) {
+ InsertPt = Inst->InsertPt;
+ PhysLiveRegs = Inst->PhysLiveRegs;
+ } else {
+ InsertPt = MBB.getFirstTerminator();
+ PhysLiveRegs = Block.PhysLiveRegsAtExit;
+ }
+ if (!(PhysLiveRegs & LiveRegs::NZCV))
+ return {InsertPt, PhysLiveRegs}; // Nothing to do (no live flags).
+ // Find the previous state change. We can not move before this point.
+ MachineBasicBlock::iterator PrevStateChangeI;
+ if (Inst == Block.Insts.begin())
+ PrevStateChangeI = MBB.begin();
+ else
+ PrevStateChangeI = std::prev(Inst)->InsertPt;
----------------
SamTebbs33 wrote:
How do we know that state was changed at the point of the previous instruction? Won't that mean that the loop after this will only execute one iteration since it will start with `InsertPt`, then go to `--InsertPt`, at which point it will stop because that is `PrevStateChangeI`?
https://github.com/llvm/llvm-project/pull/161353
More information about the llvm-commits
mailing list