summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVictor Lomuller <victor@codeplay.com>2018-02-12 21:42:15 +0000
committerDiego Novillo <dnovillo@google.com>2018-02-27 08:52:46 -0500
commit3497a94460ebd865c9d08483cdffac1fcde0c528 (patch)
tree56652958f4d7a12505324dc62f3f21a114ec6f1a /tools
parente354984b09624c7fa2200e40555c98ca1a8fa5c6 (diff)
Add loop unswitch pass.
It moves all conditional branching and switch whose conditions are loop invariant and uniform. Before performing the loop unswitch we check that the loop does not contain any instruction that would prevent it (barriers, group instructions etc.).
Diffstat (limited to 'tools')
-rw-r--r--tools/opt/opt.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 3f8dd884..9c9a2710 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -187,6 +187,10 @@ Options (in lexicographical order):
--local-redundancy-elimination
Looks for instructions in the same basic block that compute the
same value, and deletes the redundant ones.
+ --loop-unswitch
+ Hoists loop-invariant conditionals out of loops by duplicating
+ the loop on each branch of the conditional and adjusting each
+ copy of the loop.
-O
Optimize for performance. Apply a sequence of transformations
in an attempt to improve the performance of the generated
@@ -463,6 +467,8 @@ OptStatus ParseFlags(int argc, const char** argv, Optimizer* optimizer,
optimizer->RegisterPass(CreateDeadVariableEliminationPass());
} else if (0 == strcmp(cur_arg, "--fold-spec-const-op-composite")) {
optimizer->RegisterPass(CreateFoldSpecConstantOpAndCompositePass());
+ } else if (0 == strcmp(cur_arg, "--loop-unswitch")) {
+ optimizer->RegisterPass(CreateLoopUnswitchPass());
} else if (0 == strcmp(cur_arg, "--scalar-replacement")) {
optimizer->RegisterPass(CreateScalarReplacementPass());
} else if (0 == strcmp(cur_arg, "--strength-reduction")) {