[llvm] [MachinePipeliner] Add an abstract layer to manipulate Data Dependenc… (PR #109918)
Michael Marjieh via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 2 23:22:08 PST 2025
================
@@ -114,10 +115,123 @@ class MachinePipeliner : public MachineFunctionPass {
bool useWindowScheduler(bool Changed);
};
+/// Represents a dependence between two instruction.
+class SwingSchedulerDDGEdge {
+ SUnit *Dst = nullptr;
+ SDep Pred;
+ unsigned Distance = 0;
+
+public:
+ /// Creates an edge corresponding to an edge represented by \p PredOrSucc and
+ /// \p Dep in the original DAG. This pair has no information about the
+ /// direction of the edge, so we need to pass an additional argument \p
+ /// IsSucc.
+ SwingSchedulerDDGEdge(SUnit *PredOrSucc, const SDep &Dep, bool IsSucc)
+ : Dst(PredOrSucc), Pred(Dep), Distance(0u) {
+ SUnit *Src = Dep.getSUnit();
+
+ if (IsSucc) {
+ std::swap(Src, Dst);
+ Pred.setSUnit(Src);
+ }
+
+ // An anti-dependence to PHI means loop-carried dependence.
+ if (Pred.getKind() == SDep::Anti && Src->getInstr()->isPHI()) {
+ Distance = 1;
+ std::swap(Src, Dst);
+ auto Reg = Pred.getReg();
+ Pred = SDep(Src, SDep::Kind::Data, Reg);
----------------
mmarjieh wrote:
I found the issue I think.
I had a bug (compiler crash on assertion) on an offline target (not in LLVM community).
I investigated and got to a conclusion that this is the issue.
You changed the phi anti-dep handling.
So when originally having,
some_instruction -> phi; anti dep
You have in your new DAG:
some_instruction -> phi, data dep
In the original consideration, some_instruction is a successor of the phi with anit-dep.
and it was missed out in succ_l.
See my fix, does it make sense to you?
![image](https://github.com/user-attachments/assets/e55ce3c3-9c3d-444b-98ea-0af859d67454)
https://github.com/llvm/llvm-project/pull/109918
More information about the llvm-commits
mailing list