[polly] [Polly] Add vectorize metadata to loops identified as vectorizable by polly (PR #113994)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 04:41:56 PST 2024


================
@@ -128,8 +128,28 @@ void ScopAnnotator::popLoop(bool IsParallel) {
   LoopAttrEnv.pop_back();
 }
 
-void ScopAnnotator::annotateLoopLatch(BranchInst *B, Loop *L, bool IsParallel,
-                                      bool IsLoopVectorizerDisabled) const {
+void ScopAnnotator::addVectorizeMetadata(LLVMContext &Ctx,
+                                         SmallVector<Metadata *, 3> *Args,
+                                         bool EnableLoopVectorizer) const {
+  MDString *PropName = MDString::get(Ctx, "llvm.loop.vectorize.enable");
+  ConstantInt *Value =
+      ConstantInt::get(Type::getInt1Ty(Ctx), EnableLoopVectorizer);
+  ValueAsMetadata *PropValue = ValueAsMetadata::get(Value);
+  Args->push_back(MDNode::get(Ctx, {PropName, PropValue}));
+}
+
+void addParallelMetadata(LLVMContext &Ctx, SmallVector<Metadata *, 3> *Args,
+                         llvm::SmallVector<llvm::MDNode *, 8> ParallelLoops) {
+  MDString *PropName = MDString::get(Ctx, "llvm.loop.parallel_accesses");
+  MDNode *AccGroup = ParallelLoops.back();
+  Args->push_back(MDNode::get(Ctx, {PropName, AccGroup}));
+}
+
+// Last argument is optional, if no value is passed, we don't annotate
+// any vectorize metadata.
----------------
Meinersbur wrote:

Interface descriptions usually go to the declaration in the header files as Doxygen comment (`/// @param EnableVectorizeMetadata If no value is passed, we don't annotate any vectorize metadata.`)

https://github.com/llvm/llvm-project/pull/113994


More information about the llvm-commits mailing list