diff options
| author | Roman Gareev <gareevroman@gmail.com> | 2017-08-22 17:38:46 +0000 |
|---|---|---|
| committer | Roman Gareev <gareevroman@gmail.com> | 2017-08-22 17:38:46 +0000 |
| commit | 0956a606ffb17395f02a58ff7893b0297dcd9875 (patch) | |
| tree | d846c1bd1883a7abe01e3b8fd071614f97ed5190 /polly/lib/CodeGen/IRBuilder.cpp | |
| parent | 595b77bc0b15000f9b8f0d75ddddb55d2aaaa59a (diff) | |
| download | bcm5719-llvm-0956a606ffb17395f02a58ff7893b0297dcd9875.tar.gz bcm5719-llvm-0956a606ffb17395f02a58ff7893b0297dcd9875.zip | |
Disable the Loop Vectorizer in case of GEMM
Currently, in case of GEMM and the pattern matching based optimizations, we
use only the SLP Vectorizer out of two LLVM vectorizers. Since the Loop
Vectorizer can get in the way of optimal code generation, we disable the Loop
Vectorizer for the innermost loop using mark nodes and emitting the
corresponding metadata.
Reviewed-by: Tobias Grosser <tobias@grosser.es>
Differential Revision: https://reviews.llvm.org/D36928
llvm-svn: 311473
Diffstat (limited to 'polly/lib/CodeGen/IRBuilder.cpp')
| -rw-r--r-- | polly/lib/CodeGen/IRBuilder.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/polly/lib/CodeGen/IRBuilder.cpp b/polly/lib/CodeGen/IRBuilder.cpp index 94cdda2ec85..1ad01a4a98b 100644 --- a/polly/lib/CodeGen/IRBuilder.cpp +++ b/polly/lib/CodeGen/IRBuilder.cpp @@ -114,15 +114,27 @@ void ScopAnnotator::popLoop(bool IsParallel) { ParallelLoops.pop_back(); } -void ScopAnnotator::annotateLoopLatch(BranchInst *B, Loop *L, - bool IsParallel) const { - if (!IsParallel) - return; +void ScopAnnotator::annotateLoopLatch(BranchInst *B, Loop *L, bool IsParallel, + bool IsLoopVectorizerDisabled) const { + MDNode *MData = nullptr; + + if (IsLoopVectorizerDisabled) { + SmallVector<Metadata *, 3> Args; + LLVMContext &Ctx = SE->getContext(); + Args.push_back(MDString::get(Ctx, "llvm.loop.vectorize.enable")); + auto *FalseValue = ConstantInt::get(Type::getInt1Ty(Ctx), 0); + Args.push_back(ValueAsMetadata::get(FalseValue)); + MData = MDNode::concatenate(MData, getID(Ctx, MDNode::get(Ctx, Args))); + } + + if (IsParallel) { + assert(!ParallelLoops.empty() && "Expected a parallel loop to annotate"); + MDNode *Ids = ParallelLoops.back(); + MDNode *Id = cast<MDNode>(Ids->getOperand(Ids->getNumOperands() - 1)); + MData = MDNode::concatenate(MData, Id); + } - assert(!ParallelLoops.empty() && "Expected a parallel loop to annotate"); - MDNode *Ids = ParallelLoops.back(); - MDNode *Id = cast<MDNode>(Ids->getOperand(Ids->getNumOperands() - 1)); - B->setMetadata("llvm.loop", Id); + B->setMetadata("llvm.loop", MData); } /// Get the pointer operand |

