Debian Codegraph @

pypy/doc/config/translation.backendopt.merge_if_blocks.txt

raw
1 This optimization converts parts of flow graphs that result from
2 chains of ifs and elifs like this into merged blocks.
3
4 By default flow graphing this kind of code::
5
6 if x == 0:
7 f()
8 elif x == 1:
9 g()
10 elif x == 4:
11 h()
12 else:
13 j()
14
15 will result in a chain of blocks with two exits, somewhat like this:
16
17 .. image:: unmergedblocks.png
18
19 (reflecting how Python would interpret this code). Running this
20 optimization will transform the block structure to contain a single
21 "choice block" with four exits:
22
23 .. image:: mergedblocks.png
24
25 This can then be turned into a switch by the C backend, allowing the C
26 compiler to produce more efficient code.