summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGLoopInfo.cpp
diff options
context:
space:
mode:
authorTyler Nowicki <tyler.nowicki@gmail.com>2015-06-11 23:23:17 +0000
committerTyler Nowicki <tyler.nowicki@gmail.com>2015-06-11 23:23:17 +0000
commit9d268e178ec8101fa2a483e6cfc6ddb42c567ce9 (patch)
tree961172bda0c1243bf5909cf43c5f120ef7625de3 /clang/lib/CodeGen/CGLoopInfo.cpp
parentc974a9e50d3a5159ca6552a77eec8cc7491563d6 (diff)
downloadbcm5719-llvm-9d268e178ec8101fa2a483e6cfc6ddb42c567ce9.tar.gz
bcm5719-llvm-9d268e178ec8101fa2a483e6cfc6ddb42c567ce9.zip
Add assume_safety option for pragma loop vectorize and interleave.
Specifying #pragma clang loop vectorize(assume_safety) on a loop adds the mem.parallel_loop_access metadata to each load/store operation in the loop. This metadata tells loop access analysis (LAA) to skip memory dependency checking. llvm-svn: 239572
Diffstat (limited to 'clang/lib/CodeGen/CGLoopInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGLoopInfo.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp
index 0675544bedf..3254fb81dcc 100644
--- a/clang/lib/CodeGen/CGLoopInfo.cpp
+++ b/clang/lib/CodeGen/CGLoopInfo.cpp
@@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===//
#include "CGLoopInfo.h"
+#include "clang/AST/Attr.h"
+#include "clang/Sema/LoopHint.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
@@ -76,7 +78,33 @@ LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes &Attrs)
LoopID = createMetadata(Header->getContext(), Attrs);
}
-void LoopInfoStack::push(BasicBlock *Header) {
+void LoopInfoStack::push(BasicBlock *Header, ArrayRef<const Attr *> Attrs) {
+ for (const auto *Attr : Attrs) {
+ const LoopHintAttr *LH = dyn_cast<LoopHintAttr>(Attr);
+
+ // Skip non loop hint attributes
+ if (!LH)
+ continue;
+
+ LoopHintAttr::OptionType Option = LH->getOption();
+ LoopHintAttr::LoopHintState State = LH->getState();
+ switch (Option) {
+ case LoopHintAttr::Vectorize:
+ case LoopHintAttr::Interleave:
+ if (State == LoopHintAttr::AssumeSafety) {
+ // Apply "llvm.mem.parallel_loop_access" metadata to load/stores.
+ setParallel(true);
+ }
+ break;
+ case LoopHintAttr::VectorizeWidth:
+ case LoopHintAttr::InterleaveCount:
+ case LoopHintAttr::Unroll:
+ case LoopHintAttr::UnrollCount:
+ // Nothing to do here for these loop hints.
+ break;
+ }
+ }
+
Active.push_back(LoopInfo(Header, StagedAttrs));
// Clear the attributes so nested loops do not inherit them.
StagedAttrs.clear();
OpenPOWER on IntegriCloud