[llvm] [ModuloSchedule] Implement modulo variable expansion for pipelining (PR #65609)
Yuta Mukai via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 06:09:43 PDT 2024
================
@@ -9631,48 +9888,76 @@ AArch64InstrInfo::analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const {
return nullptr;
// Must be conditional branch
- if (FBB == nullptr)
+ if (TBB != LoopBB && FBB == nullptr)
return nullptr;
assert((TBB == LoopBB || FBB == LoopBB) &&
"The Loop must be a single-basic-block loop");
+ MachineInstr *CondBranch = &*LoopBB->getFirstTerminator();
+ const TargetRegisterInfo &TRI = getRegisterInfo();
+
+ if (CondBranch->getOpcode() != AArch64::Bcc)
+ return nullptr;
+
// Normalization for createTripCountGreaterCondition()
if (TBB == LoopBB)
reverseBranchCondition(Cond);
- MachineInstr *CondBranch = &*LoopBB->getFirstTerminator();
- const TargetRegisterInfo &TRI = getRegisterInfo();
-
- // Find the immediate predecessor of the conditional branch
- MachineInstr *PredBranch = nullptr;
- if (CondBranch->getOpcode() == AArch64::Bcc) {
- for (MachineInstr &MI : reverse(*LoopBB)) {
- if (MI.modifiesRegister(AArch64::NZCV, &TRI)) {
- PredBranch = &MI;
+ MachineInstr *Comp = nullptr;
+ unsigned CompCounterOprNum = 0;
+ for (MachineInstr &MI : reverse(*LoopBB)) {
+ if (MI.modifiesRegister(AArch64::NZCV, &TRI)) {
----------------
ytmukai wrote:
All other instructions that use NZCV are scheduled in the first stage (not pipelined). This means that their NZCV def-use do not cross blocks. Thus, they do not interfere each other with the use of NZCV for loop control.
That case is tested by https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/AArch64/sms-unpipeline-insts1.mir.
In addition, it seems that a case in which NZCV is referenced across loops is considered an undefined reference.
https://godbolt.org/z/PP3fzdd8a
https://github.com/llvm/llvm-project/pull/65609
More information about the llvm-commits
mailing list