annotate include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents
children 3a76565eade5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 //===- SimpleLoopUnswitch.h - Hoist loop-invariant control flow -*- C++ -*-===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 #ifndef LLVM_TRANSFORMS_SCALAR_SIMPLELOOPUNSWITCH_H
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 #define LLVM_TRANSFORMS_SCALAR_SIMPLELOOPUNSWITCH_H
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 #include "llvm/Analysis/LoopAnalysisManager.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14 #include "llvm/Analysis/LoopInfo.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 #include "llvm/IR/PassManager.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16 #include "llvm/Transforms/Scalar/LoopPassManager.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 namespace llvm {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 /// This pass transforms loops that contain branches on loop-invariant
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 /// conditions to have multiple loops. For example, it turns the left into the
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 /// right code:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 ///
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 /// for (...) if (lic)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 /// A for (...)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26 /// if (lic) A; B; C
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27 /// B else
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 /// C for (...)
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 /// A; C
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 ///
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 /// This can increase the size of the code exponentially (doubling it every time
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 /// a loop is unswitched) so we only unswitch if the resultant code will be
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 /// smaller than a threshold.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 ///
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 /// This pass expects LICM to be run before it to hoist invariant conditions out
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 /// of the loop, to make the unswitching opportunity obvious.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 ///
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 class SimpleLoopUnswitchPass : public PassInfoMixin<SimpleLoopUnswitchPass> {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39 public:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 SimpleLoopUnswitchPass() = default;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42 PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 LoopStandardAnalysisResults &AR, LPMUpdater &U);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 };
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 /// Create the legacy pass object for the simple loop unswitcher.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47 ///
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 /// See the documentaion for `SimpleLoopUnswitchPass` for details.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49 Pass *createSimpleLoopUnswitchLegacyPass();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
51 } // end namespace llvm
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53 #endif // LLVM_TRANSFORMS_SCALAR_SIMPLELOOPUNSWITCH_H