annotate include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h @ 134:3a76565eade5 LLVM5.0.1

update 5.0.1
author mir3636
date Sat, 17 Feb 2018 09:57:20 +0900
parents 803732b1fca8
children c2174574ed3a
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> {
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
39 bool NonTrivial;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
40
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 public:
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
42 SimpleLoopUnswitchPass(bool NonTrivial = false) : NonTrivial(NonTrivial) {}
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45 LoopStandardAnalysisResults &AR, LPMUpdater &U);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 };
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 /// Create the legacy pass object for the simple loop unswitcher.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49 ///
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50 /// See the documentaion for `SimpleLoopUnswitchPass` for details.
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
51 Pass *createSimpleLoopUnswitchLegacyPass(bool NonTrivial = false);
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53 } // end namespace llvm
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
54
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
55 #endif // LLVM_TRANSFORMS_SCALAR_SIMPLELOOPUNSWITCH_H