summaryrefslogtreecommitdiff
path: root/tools/opt/opt.cpp
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2013-12-05 21:20:02 +0000
committerRenato Golin <renato.golin@linaro.org>2013-12-05 21:20:02 +0000
commit07d9471bc59dea5069991b4cf9602f6b6404418b (patch)
treee85b76b1232ec4f3f593b7dd4ab16378bce4ecba /tools/opt/opt.cpp
parent226e3eab9bb39e6b73122c26532cfa8242eb6d4e (diff)
downloadllvm-07d9471bc59dea5069991b4cf9602f6b6404418b.tar.gz
llvm-07d9471bc59dea5069991b4cf9602f6b6404418b.tar.bz2
llvm-07d9471bc59dea5069991b4cf9602f6b6404418b.tar.xz
Add #pragma vectorize enable/disable to LLVM
The intended behaviour is to force vectorization on the presence of the flag (either turn on or off), and to continue the behaviour as expected in its absence. Tests were added to make sure the all cases are covered in opt. No tests were added in other tools with the assumption that they should use the PassManagerBuilder in the same way. This patch also removes the outdated -late-vectorize flag, which was on by default and not helping much. The pragma metadata is being attached to the same place as other loop metadata, but nothing forbids one from attaching it to a function (to enable #pragma optimize) or basic blocks (to hint the basic-block vectorizers), etc. The logic should be the same all around. Patches to Clang to produce the metadata will be produced after the initial implementation is agreed upon and committed. Patches to other vectorizers (such as SLP and BB) will be added once we're happy with the pass manager changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt/opt.cpp')
-rw-r--r--tools/opt/opt.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index dba16f72da..5e27c09cdd 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -471,8 +471,14 @@ static void AddOptimizationPasses(PassManagerBase &MPM,FunctionPassManager &FPM,
Builder.DisableUnrollLoops = (DisableLoopUnrolling.getNumOccurrences() > 0) ?
DisableLoopUnrolling : OptLevel == 0;
- Builder.LoopVectorize =
- DisableLoopVectorization ? false : OptLevel > 1 && SizeLevel < 2;
+ // This is final, unless there is a #pragma vectorize enable
+ if (DisableLoopVectorization)
+ Builder.LoopVectorize = false;
+ // If option wasn't forced via cmd line (-vectorize-loops, -loop-vectorize)
+ else if (!Builder.LoopVectorize)
+ Builder.LoopVectorize = OptLevel > 1 && SizeLevel < 2;
+
+ // When #pragma vectorize is on for SLP, do the same as above
Builder.SLPVectorize =
DisableSLPVectorization ? false : OptLevel > 1 && SizeLevel < 2;