https://discourse.llvm.org/t/incorrect-recmii-calculations-in-machinepipeliner/63531
The pipeliner's calculation of RecMII depends on the 'Latency' calculated
from each elementary circuit.
Consider the follow example: a DAG with a triange dependence of the form:
1 -> 2, 1 -> 3, 2 -> 3, and 3 -> 1
Assume edges are all weighted 1.
The current calculation for NodeSet Latency checks only that the successor
is in the circuit, and not that the successor is part of the path taken by
the particular elementary circuit.
This presents as the following with the given DAG:
- Circuit 1 -> 3 correctly calculated as Latency = 1
- Circuit 1 -> 2 -> 3 incorrectly calculated as Latency = 3 and not 2
The solution here notes that Johnson's algorithm returns the elementary
circuit in the order that the path is taken. This fact is used to ensure
that only edges to the immediate successor in the circuit is checked for
latency.
I've added a common-thread reviewer for a few past commits, but welcome others to add and review themselves.
The subscribers I've added are colleagues as well as past MachinePipeliner committers as interested parties.
As an aside: Are discourse links static and persistent? Or should I remove it from the log here and only reference it in the review?
This relies on "notes that Johnson's algorithm returns the elementary circuit in the order that the path is taken". Could you add this as a comment here, maybe even add a note at line 321 to SetVector Node, that Node needs to be ordered (and the SetVector isn't there just to avoid non-determinism).
Can you also add a pointer to the fact that it does reutrn the path in order (I myself for example didn't know this).