Commit Graph

13 Commits

Author SHA1 Message Date
Pietro Fezzardi 48749974f0 IDS: simplifyTerminator doesn't merge default
With this commit, the `simplifyTerminator` helper function used by IDS
stops trying to merge the default cases with one of the other cases
arbitrarily.
Now, if the `UnreachableSuccessor` was reached via the default case, the
default case is still arbitrarily redirected to an arbitrary case
successor, but the case and the default do not get merged.
This keeps the logic of the transform simpler, and also allows for
easier successive manipulation by planned upcoming transforms.
2025-11-06 13:32:56 +01:00
Pietro Fezzardi 1480a3f0aa Move simplifyTerminator into IDS source file
The implementation of `simplifyTerminator` is very specific to the
operations of IDS, can be easily misused, and is not currently used
anywhere else in the codebase.
2025-11-06 13:32:56 +01:00
Ivan Krysak 2ba5ca3e3d Suppress selected IRBuilder checks 2025-10-21 19:17:37 +03:00
Ivan Krysak 3561c2b907 Adopt IRBuilder wrapper 2025-10-21 19:17:01 +03:00
Andrea Gussoni a5c1fdb3fe IDS: assert no disconnected blocks 2025-09-24 15:51:06 +02:00
Andrea Gussoni fbd8c827e1 ScopeGraph: move helper functions
Move the `replaceSuccessors` and `simplifyTerminator` helper in the
`ScopeGraphUtils` library.
2025-09-10 13:36:08 +02:00
Andrea Gussoni 4bfef217b6 IDS: preserve dbg metadata 2025-09-10 13:36:07 +02:00
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