diff options
author | Valentin Clement <clementval@gmail.com> | 2023-07-21 21:46:20 -0700 |
---|---|---|
committer | Valentin Clement <clementval@gmail.com> | 2023-07-21 21:46:50 -0700 |
commit | d4f24163985c87d6c5df2d429786206777ab97ec (patch) | |
tree | bc610a45d14d0e7c658a2a367fb2f40369cffeb8 /flang | |
parent | c9d419c1df72b0160e374f8d0b9f30508b3b98a7 (diff) | |
download | llvm-d4f24163985c87d6c5df2d429786206777ab97ec.zip llvm-d4f24163985c87d6c5df2d429786206777ab97ec.tar.gz llvm-d4f24163985c87d6c5df2d429786206777ab97ec.tar.bz2 |
[flang][openacc] Fix hasDynamicShape logic
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D155897
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Lower/OpenACC.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index e1332f1..565ce5b 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; |