[flang-commits] [flang] [flang][openacc] Keep constant bounds in reduction recipe when it is all constants (PR #67827)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Mon Oct 2 14:19:35 PDT 2023


================
@@ -478,6 +478,34 @@ mlir::acc::FirstprivateRecipeOp Fortran::lower::createOrGetFirstprivateRecipe(
   return recipe;
 }
 
+/// Get a string representation of the bounds.
+std::string getBoundsString(llvm::SmallVector<mlir::Value> &bounds) {
+  std::stringstream boundStr;
+  bool addSeparator = false;
+  if (!bounds.empty())
+    boundStr << "_section_";
+  for (auto bound : bounds) {
+    auto boundsOp =
+        mlir::dyn_cast<mlir::acc::DataBoundsOp>(bound.getDefiningOp());
+    if (boundsOp.getLowerbound() &&
+        fir::getIntIfConstant(boundsOp.getLowerbound()) &&
+        boundsOp.getUpperbound() &&
+        fir::getIntIfConstant(boundsOp.getUpperbound())) {
+      boundStr << "lb" << *fir::getIntIfConstant(boundsOp.getUpperbound())
+               << ".ub" << *fir::getIntIfConstant(boundsOp.getLowerbound());
+    } else if (boundsOp.getExtent() &&
+               fir::getIntIfConstant(boundsOp.getExtent())) {
+      boundStr << "ext" << *fir::getIntIfConstant(boundsOp.getExtent());
+    } else {
+      boundStr << "?";
+    }
+    if (addSeparator)
+      boundStr << "x";
----------------
clementval wrote:

Thanks for the review @vzakhari. I update the code to use `llvm::interleave` which makes more sense. 

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


More information about the flang-commits mailing list