Commit Graph

6 Commits

Author SHA1 Message Date
Andrea Gussoni be72da8b48 IDS: improve collection restart criterion
We now reduce the number of cases in which we restart the collection of
the `DivergenceDescriptor`s after a IDS modification on the `ScopeGraph`
is performed.

We previously restarted the collection after each IDS transformation.

Now, restart is only performed after IDS is applied on a `Conditional`
node whose all successors are divergent exits which are `goto` exits.
After such `Conditional` is processed, it may happen that a new `goto`
exit becomes divergent for another `Conditional` upwards in the
`ScopeGraph`.
Therefore, if we do not restart, it may happen that a non-`goto` exit is
processed before a `goto` exit, which may lead to suboptimal situations
in the emitted number of `goto`s, due to how IDS interacts with
`MaterializeTrivialGotos`.
2025-06-12 15:31:38 +02:00
Andrea Gussoni b786a657bf IDS: collect multiple divergent successors
When performing the IDS procedure for a divergence which is entered
through multiple `Successor`s of the `Conditional`, we insert a `Head`
header which collects the entry to the scope, in order to maintain
decidedness if there is a common post-dominator to all the `Successor`s
(similar to what weaving did).
2025-06-12 15:31:38 +02:00
Andrea Gussoni 3527291bd9 IDS: multiple divergence implementation
Perform the IDS transformation, by taking into account possible multiple
divergent scopes for a certain conditional node at the same time.

This reduces the run times, since it reduces the number of time IDS is
called on a conditional, but mostly proceduce a more _compact_
`ScopeGraph`, where all the divergent scopes for a certain conditional
node rejoing the path toward the one true exit in a single point,
instead of having a chain of IDS resulting regions.

Make IDS unit tests compliant with the new multiple divergence
implementation.
2025-06-12 15:31:38 +02:00
Andrea Gussoni 8b87854a11 IDS: improve goto exit ordering criterion
Perform the IDS operation for the exit nodes corresponding to `goto`
blocks afterwards the other _standard_ exits have been processed.

In addition, order the `GotoBlock`s according to the `post_order` of the
target blocks of the `goto` themselves. This should maximize the
opportunities for later runs of `MaterializeTrivialGoto`.
2025-04-30 16:10:54 +02:00
Andrea Gussoni 71988af041 Fix MIT license 2025-04-30 16:10:54 +02:00
Andrea Gussoni 40ebac06cc IDS: introduce pass
Introduce the `inline-divergent-scopes` pass. This pass in is charge of
reducing the exit nodes in a `ScopeGraph`, applying the _Inline
Divergent Scopes_ transformation, which is able, in presence of
divergent exits nodes, wrt. to a conditional, to remove the exit node
and to transform the `ScopeGraph` in a form where semantics is
preserved.
2025-04-02 16:47:14 +02:00