[flang-commits] [flang] [llvm] [mlir] [MLIR][Flang][OpenMP] Make omp.simdloop into a loop wrapper (PR #87365)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Mon Apr 15 07:58:33 PDT 2024


================
@@ -1625,46 +1643,57 @@ genLoopAndReductionVars(
   return llvm::SmallVector<const Fortran::semantics::Symbol *>(loopArgs);
 }
 
-static void
-createSimdLoop(Fortran::lower::AbstractConverter &converter,
-               Fortran::semantics::SemanticsContext &semaCtx,
-               Fortran::lower::pft::Evaluation &eval,
-               llvm::omp::Directive ompDirective,
-               const Fortran::parser::OmpClauseList &loopOpClauseList,
-               mlir::Location loc) {
+static void createSimd(Fortran::lower::AbstractConverter &converter,
+                       Fortran::semantics::SemanticsContext &semaCtx,
+                       Fortran::lower::pft::Evaluation &eval,
+                       llvm::omp::Directive ompDirective,
+                       const Fortran::parser::OmpClauseList &loopOpClauseList,
+                       mlir::Location loc) {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
   DataSharingProcessor dsp(converter, semaCtx, loopOpClauseList, eval);
   dsp.processStep1();
 
   Fortran::lower::StatementContext stmtCtx;
-  mlir::omp::SimdLoopClauseOps clauseOps;
+  mlir::omp::SimdClauseOps simdClauseOps;
+  mlir::omp::LoopNestClauseOps loopClauseOps;
   llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
 
   ClauseProcessor cp(converter, semaCtx, loopOpClauseList);
-  cp.processCollapse(loc, eval, clauseOps, iv);
-  cp.processReduction(loc, clauseOps);
-  cp.processIf(llvm::omp::Directive::OMPD_simd, clauseOps);
-  cp.processSimdlen(clauseOps);
-  cp.processSafelen(clauseOps);
-  clauseOps.loopInclusiveAttr = firOpBuilder.getUnitAttr();
+  cp.processCollapse(loc, eval, loopClauseOps, iv);
+  cp.processReduction(loc, simdClauseOps);
+  cp.processIf(llvm::omp::Directive::OMPD_simd, simdClauseOps);
+  cp.processSimdlen(simdClauseOps);
+  cp.processSafelen(simdClauseOps);
+  loopClauseOps.loopInclusiveAttr = firOpBuilder.getUnitAttr();
   // TODO Support delayed privatization.
 
   cp.processTODO<clause::Aligned, clause::Allocate, clause::Linear,
                  clause::Nontemporal, clause::Order>(loc, ompDirective);
 
+  // Create omp.simd wrapper.
+  auto simdOp = firOpBuilder.create<mlir::omp::SimdOp>(loc, simdClauseOps);
+
+  // TODO Add reduction-related arguments to the wrapper's entry block.
----------------
Meinersbur wrote:

```suggestion
  // TODO: Add reduction-related arguments to the wrapper's entry block.
```

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


More information about the flang-commits mailing list