diff options
author | Nathan Gauër <brioche@google.com> | 2024-06-03 11:35:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 11:35:55 +0200 |
commit | a5641f106affc3afb899eee42eb40c2ded81f411 (patch) | |
tree | 29b2d9960d880ce1cff4c1cacae4df1e823ecbd6 /clang/lib/Serialization/ModuleFile.cpp | |
parent | 5bfc444524d74b714b9efb2dc00c7bc36a3838e2 (diff) | |
download | llvm-a5641f106affc3afb899eee42eb40c2ded81f411.zip llvm-a5641f106affc3afb899eee42eb40c2ded81f411.tar.gz llvm-a5641f106affc3afb899eee42eb40c2ded81f411.tar.bz2 |
[SPIR-V] Add pass to merge convergence region exit targets (#92531)
The structurizer required regions to be SESE: single entry, single exit.
This new pass transforms multiple-exit regions into single-exit regions.
```
+---+
| A |
+---+
/ \
+---+ +---+
| B | | C | A, B & C belongs to the same convergence region.
+---+ +---+
| |
+---+ +---+
| D | | E | C & D belongs to the parent convergence region.
+---+ +---+ This means B & C are the exit blocks of the region.
\ / And D & E the targets of those exits.
\ /
|
+---+
| F |
+---+
```
This pass would assign one value per exit target:
B = 0
C = 1
Then, create one variable per exit block (B, C), and assign it to the
correct value: in B, the variable will have the value 0, and in C, the
value 1.
Then, we'd create a new block H, with a PHI node to gather those 2
variables, and a switch, to route to the correct target.
Finally, the branches in B and C are updated to exit to this new block.
```
+---+
| A |
+---+
/ \
+---+ +---+
| B | | C |
+---+ +---+
\ /
+---+
| H |
+---+
/ \
+---+ +---+
| D | | E |
+---+ +---+
\ /
\ /
|
+---+
| F |
+---+
```
Note: the variable is set depending on the condition used to branch. If
B's terminator was conditional, the variable would be set using a
SELECT.
All internal edges of a region are left intact, only exiting edges are
updated.
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
Diffstat (limited to 'clang/lib/Serialization/ModuleFile.cpp')
0 files changed, 0 insertions, 0 deletions