https://github.com/tblah created https://github.com/llvm/llvm-project/pull/84954

OpenMP reduction declare operations can contain FIR code which needs to be 
lowered to LLVM. With array reductions, these regions can contain more 
complicated operations which need PreCGRewriting. A similar extra case was 
already needed for fir::GlobalOp.

OpenMP array reductions 3/6

>From f951d16cf6cb1ab221f47ca2e712020b9af0af87 Mon Sep 17 00:00:00 2001
From: Tom Eccles <tom.ecc...@arm.com>
Date: Fri, 1 Mar 2024 16:59:09 +0000
Subject: [PATCH] [flang][CodeGen] Run PreCGRewrite on omp reduction declare
 ops

OpenMP reduction declare operations can contain FIR code which needs to
be lowered to LLVM. With array reductions, these regions can contain
more complicated operations which need PreCGRewriting. A similar extra
case was already needed for fir::GlobalOp.
---
 flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp 
b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
index 0170b56367cf3c..dd935e71762355 100644
--- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
@@ -22,6 +22,7 @@
 #include "mlir/Transforms/RegionUtils.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
+#include <mlir/Dialect/OpenMP/OpenMPDialect.h>
 
 namespace fir {
 #define GEN_PASS_DEF_CODEGENREWRITE
@@ -319,6 +320,10 @@ class CodeGenRewrite : public 
fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
       runOn(func, func.getBody());
     for (auto global : mod.getOps<fir::GlobalOp>())
       runOn(global, global.getRegion());
+    for (auto omp : mod.getOps<mlir::omp::ReductionDeclareOp>()) {
+      runOn(omp, omp.getInitializerRegion());
+      runOn(omp, omp.getReductionRegion());
+    }
   }
 };
 

_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
  • [... Tom Eccles via llvm-branch-commits
    • ... via llvm-branch-commits
    • ... Tom Eccles via llvm-branch-commits
    • ... Valentin Clement バレンタイン クレメン via llvm-branch-commits
    • ... Valentin Clement バレンタイン クレメン via llvm-branch-commits
    • ... Tom Eccles via llvm-branch-commits
    • ... Tom Eccles via llvm-branch-commits
    • ... Kiran Chandramohan via llvm-branch-commits
    • ... Kiran Chandramohan via llvm-branch-commits
    • ... Tom Eccles via llvm-branch-commits
    • ... via llvm-branch-commits

Reply via email to