1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/lib/Transforms/Scalar
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
..
ADCE.cpp [IR] Consider non-willreturn as side effect (PR50511) 2021-07-26 16:35:14 +02:00
AlignmentFromAssumptions.cpp Recommit [ScalarEvolution] Make getMinusSCEV() fail for unrelated pointers. 2021-07-06 12:16:05 -07:00
AnnotationRemarks.cpp
BDCE.cpp
CallSiteSplitting.cpp
CMakeLists.txt Add jump-threading optimization for deterministic finite automata 2021-07-27 14:34:04 -04:00
ConstantHoisting.cpp
ConstraintElimination.cpp
CorrelatedValuePropagation.cpp [CVP] Guard against poison in common phi value transform (PR50399) 2021-05-25 20:47:17 +02:00
DCE.cpp
DeadStoreElimination.cpp Revert "[DSE] Transform memset + malloc --> calloc (PR25892)" 2021-07-23 11:51:59 +02:00
DFAJumpThreading.cpp Add jump-threading optimization for deterministic finite automata 2021-07-27 14:34:04 -04:00
DivRemPairs.cpp [DivRemPairs] Add an initial case for hoisting to a common predecessor. 2021-07-11 10:03:07 -07:00
EarlyCSE.cpp
FlattenCFGPass.cpp
Float2Int.cpp [NFCI] Move DEBUG_TYPE definition below #includes 2021-05-30 17:31:01 +08:00
GuardWidening.cpp
GVN.cpp GVN.cpp - remove unused <vector> include. NFCI. 2021-06-13 14:06:32 +01:00
GVNHoist.cpp
GVNSink.cpp
InductiveRangeCheckElimination.cpp
IndVarSimplify.cpp
InferAddressSpaces.cpp [infer-address-spaces] Handle complex non-pointer constexpr arguments. 2021-07-19 12:15:52 -07:00
InstSimplifyPass.cpp
IVUsersPrinter.cpp
JumpThreading.cpp [CSSPGO] Undoing the concept of dangling pseudo probe 2021-06-18 15:14:11 -07:00
LICM.cpp Strip undef implying attributes when moving calls 2021-07-27 10:57:05 -04:00
LoopAccessAnalysisPrinter.cpp
LoopBoundSplit.cpp [LoopBoundSplit] Ignore phi node which is not scevable 2021-06-09 09:44:36 +01:00
LoopDataPrefetch.cpp [NFCI] Move DEBUG_TYPE definition below #includes 2021-05-30 17:31:01 +08:00
LoopDeletion.cpp [LoopDeletion] Handle switch in proving that loop exits on first iteration 2021-07-09 18:03:34 +07:00
LoopDistribute.cpp
LoopFlatten.cpp [LoopFlatten] Use SCEV and Loop APIs to identify increment and trip count 2021-07-27 08:42:59 +01:00
LoopFuse.cpp
LoopIdiomRecognize.cpp [LoopIdiom] Transform memmove-like loop into memmove (PR46179) 2021-07-22 13:05:43 +02:00
LoopInstSimplify.cpp
LoopInterchange.cpp [LoopInterchange] Check lcssa phis in the inner latch in scenarios of multi-level nested loops 2021-07-16 11:59:20 -04:00
LoopLoadElimination.cpp [NFC] Inline variable to prevent unused variable warning 2021-07-13 09:57:59 -07:00
LoopPassManager.cpp
LoopPredication.cpp
LoopRerollPass.cpp [LoopReroll] Add an extra defensive check to avoid SCEV assertion. 2021-07-13 12:17:09 -07:00
LoopRotation.cpp
LoopSimplifyCFG.cpp
LoopSink.cpp
LoopStrengthReduce.cpp Handle unused variable when assertions are disabled 2021-07-27 15:43:06 +02:00
LoopUnrollAndJamPass.cpp LoopUnrollAndJamPass.cpp - remove unused <vector> include. NFCI. 2021-06-13 14:06:32 +01:00
LoopUnrollPass.cpp [LoopUnroll] Don't modify TripCount/TripMultiple in computeUnrollCount() (NFCI) 2021-06-21 21:34:17 +02:00
LoopUnswitch.cpp
LoopVersioningLICM.cpp
LowerAtomic.cpp
LowerConstantIntrinsics.cpp
LowerExpectIntrinsic.cpp
LowerGuardIntrinsic.cpp
LowerMatrixIntrinsics.cpp [Matrix] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build after D106457. NFC 2021-07-22 11:33:02 -07:00
LowerWidenableCondition.cpp
MakeGuardsExplicit.cpp
MemCpyOptimizer.cpp Revert "[MemCpyOpt] Enable memcpy optimizations unconditionally." 2021-07-19 14:27:41 -07:00
MergedLoadStoreMotion.cpp
MergeICmps.cpp [MergeICmps] Collect block instructions once (NFC) 2021-07-26 18:07:20 +02:00
NaryReassociate.cpp
NewGVN.cpp
PartiallyInlineLibCalls.cpp [PartiallyInlineLibCalls] Disable sqrt expansion for strictfp. 2021-06-17 14:15:12 -07:00
PlaceSafepoints.cpp
Reassociate.cpp
Reg2Mem.cpp
RewriteStatepointsForGC.cpp [RS4GC] Use one DVCache for both inlineGetBaseAndOffset() and insertParsePoints() 2021-07-12 18:13:00 +07:00
Scalar.cpp Add jump-threading optimization for deterministic finite automata 2021-07-27 14:34:04 -04:00
ScalarizeMaskedMemIntrin.cpp [ScalarizeMaskedMemIntrin][SelectionDAGBuilder] Use the element type to calculate alignment for gather/scatter when alignment operand is 0. 2021-07-01 19:08:47 -07:00
Scalarizer.cpp Update @llvm.powi to handle different int sizes for the exponent 2021-06-17 09:38:28 +02:00
SCCP.cpp [Local] Do not introduce a new llvm.trap before unreachable 2021-07-26 23:33:36 -05:00
SeparateConstOffsetFromGEP.cpp
SimpleLoopUnswitch.cpp [SimpleLoopUnswitch] Don't non-trivially unswitch loops with catchswitch exits 2021-07-14 14:07:28 -07:00
SimplifyCFGPass.cpp [SimplifyCFG] Tail-merging all blocks with resume terminator 2021-06-24 21:25:06 +03:00
Sink.cpp
SpeculativeExecution.cpp
SROA.cpp [SROA] avoid crash on memset with constant expression length 2021-07-21 15:20:28 -04:00
StraightLineStrengthReduce.cpp
StructurizeCFG.cpp
TailRecursionElimination.cpp
WarnMissedTransforms.cpp