diff options
author | Hua Tian <akiratian@tencent.com> | 2024-06-19 15:15:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 15:15:37 +0800 |
commit | dd1d2b7cb083e870174d50627870c835d1e118e6 (patch) | |
tree | 11e08c9d479d9c45d8b956b298f0111ea764af3d /llvm/lib/CodeGen | |
parent | 6c01011db089bae22630922e1ac30e5d49de3137 (diff) | |
download | llvm-dd1d2b7cb083e870174d50627870c835d1e118e6.zip llvm-dd1d2b7cb083e870174d50627870c835d1e118e6.tar.gz llvm-dd1d2b7cb083e870174d50627870c835d1e118e6.tar.bz2 |
[llvm][CodeGen] Fix failure in window scheduler caused by phi (#95900)
In certain cases, the register passed with the kernel MBB in phi are not
defined within the kernel MBB. This patch adds the corresponding handling.
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/WindowScheduler.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/WindowScheduler.cpp b/llvm/lib/CodeGen/WindowScheduler.cpp index 418309b..7a86351 100644 --- a/llvm/lib/CodeGen/WindowScheduler.cpp +++ b/llvm/lib/CodeGen/WindowScheduler.cpp @@ -533,9 +533,12 @@ void WindowScheduler::schedulePhi(int Offset, unsigned &II) { // The anti-dependency of phi need to be handled separately in the same way. if (Register AntiReg = getAntiRegister(&Phi)) { auto *AntiMI = MRI->getVRegDef(AntiReg); - auto AntiCycle = getOriCycle(AntiMI); - if (getOriStage(getOriMI(AntiMI), Offset) == 0) - LateCycle = std::min(LateCycle, AntiCycle); + // AntiReg may be defined outside the kernel MBB. + if (AntiMI->getParent() == MBB) { + auto AntiCycle = getOriCycle(AntiMI); + if (getOriStage(getOriMI(AntiMI), Offset) == 0) + LateCycle = std::min(LateCycle, AntiCycle); + } } // If there is no limit to the late cycle, a default value is given. if (LateCycle == INT_MAX) @@ -683,7 +686,7 @@ Register WindowScheduler::getAntiRegister(MachineInstr *Phi) { for (auto MO : Phi->uses()) { if (MO.isReg()) AntiReg = MO.getReg(); - else if (MO.isMBB() && MO.getMBB()->getNumber() == MBB->getNumber()) + else if (MO.isMBB() && MO.getMBB() == MBB) return AntiReg; } return 0; |