[flang-commits] [flang] d4f2416 - [flang][openacc] Fix hasDynamicShape logic

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Fri Jul 21 21:46:57 PDT 2023


Author: Valentin Clement
Date: 2023-07-21T21:46:50-07:00
New Revision: d4f24163985c87d6c5df2d429786206777ab97ec

URL: https://github.com/llvm/llvm-project/commit/d4f24163985c87d6c5df2d429786206777ab97ec
DIFF: https://github.com/llvm/llvm-project/commit/d4f24163985c87d6c5df2d429786206777ab97ec.diff

LOG: [flang][openacc] Fix hasDynamicShape logic

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D155897

Added: 
    

Modified: 
    flang/lib/Lower/OpenACC.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index e1332f17d27711..565ce5bba518db 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -680,15 +680,24 @@ static R getReductionInitValue(mlir::acc::ReductionOperator op, mlir::Type ty) {
   llvm_unreachable("OpenACC reduction unsupported type");
 }
 
+/// Check if the DataBoundsOp is a constant bound (lb and ub are constants or
+/// extent is a constant).
+bool isConstantBound(mlir::acc::DataBoundsOp &op) {
+  if (op.getLowerbound() && fir::getIntIfConstant(op.getLowerbound()) &&
+      op.getUpperbound() && fir::getIntIfConstant(op.getUpperbound()))
+    return true;
+  if (op.getExtent() && fir::getIntIfConstant(op.getExtent()))
+    return true;
+  return false;
+}
+
 /// Determine if the bounds represent a dynamic shape.
 bool hasDynamicShape(llvm::SmallVector<mlir::Value> &bounds) {
   if (bounds.empty())
     return false;
   for (auto b : bounds) {
     auto op = mlir::dyn_cast<mlir::acc::DataBoundsOp>(b.getDefiningOp());
-    if (((op.getLowerbound() && !fir::getIntIfConstant(op.getLowerbound())) ||
-         (op.getUpperbound() && !fir::getIntIfConstant(op.getUpperbound()))) &&
-        op.getExtent() && !fir::getIntIfConstant(op.getExtent()))
+    if (!isConstantBound(op))
       return true;
   }
   return false;


        


More information about the flang-commits mailing list