[llvm] [mlir] [MLIR][OpenMP] add interchange operation in the OpenMP mlir dialect (PR #186381)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 05:03:31 PDT 2026


================
@@ -4154,6 +4154,46 @@ static LogicalResult applyFuse(omp::FuseOp op, llvm::IRBuilderBase &builder,
   return success();
 }
 
+/// Apply a `#pragma omp interchange` / `!$omp interchange` transformation using
+/// the OpenMPIRBuilder.
+static LogicalResult
+applyInterchange(omp::InterchangeOp op, llvm::IRBuilderBase &builder,
+                 LLVM::ModuleTranslation &moduleTranslation) {
+  llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
+  llvm::OpenMPIRBuilder::LocationDescription loc(builder);
+
+  SmallVector<llvm::CanonicalLoopInfo *> translatedLoops;
+
+  for (Value applyee : op.getApplyees()) {
+    llvm::CanonicalLoopInfo *consBuilderCLI =
+        moduleTranslation.lookupOMPLoop(applyee);
+    assert(applyee && "Canonical loop must already been translated");
+    translatedLoops.push_back(consBuilderCLI);
+  }
+
+  auto perm = op.getPermutation().value();
+  std::vector<int> permutation;
----------------
Meinersbur wrote:

```suggestion
  SmallVector<int> permutation;
```

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


More information about the llvm-commits mailing list