1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
llvm-mirror/lib/Passes
Alexey Zhikhartsev 6516543c4b Add jump-threading optimization for deterministic finite automata
The current JumpThreading pass does not jump thread loops since it can
result in irreducible control flow that harms other optimizations. This
prevents switch statements inside a loop from being optimized to use
unconditional branches.

This code pattern occurs in the core_state_transition function of
Coremark. The state machine can be implemented manually with goto
statements resulting in a large runtime improvement, and this transform
makes the switch implementation match the goto version in performance.

This patch specifically targets switch statements inside a loop that
have the opportunity to be threaded. Once it identifies an opportunity,
it creates new paths that branch directly to the correct code block.
For example, the left CFG could be transformed to the right CFG:

```
          sw.bb                        sw.bb
        /   |   \                    /   |   \
   case1  case2  case3          case1  case2  case3
        \   |   /                /       |       \
        latch.bb             latch.2  latch.3  latch.1
         br sw.bb              /         |         \
                           sw.bb.2     sw.bb.3     sw.bb.1
                            br case2    br case3    br case1
```

Co-author: Justin Kreiner @jkreiner
Co-author: Ehsan Amiri @amehsan

Reviewed By: SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D99205
2021-07-27 14:34:04 -04:00
..
CMakeLists.txt [NewPM] Add C bindings for new pass manager 2021-05-17 11:45:47 -07:00
PassBuilder.cpp Add jump-threading optimization for deterministic finite automata 2021-07-27 14:34:04 -04:00
PassBuilderBindings.cpp [Coroutines] Run coroutine passes by default 2021-07-15 14:33:40 +08:00
PassPlugin.cpp [NPM] Resolve llvmGetPassPluginInfo to the plugin being loaded 2021-06-30 18:11:28 +01:00
PassRegistry.def Add jump-threading optimization for deterministic finite automata 2021-07-27 14:34:04 -04:00
StandardInstrumentations.cpp [NewPM] Print pre-transformation IR name in --print-after-all 2021-07-20 10:20:10 -07:00