Skip to content

Commit

Permalink
[flang][openacc] Fix hasDynamicShape logic
Browse files Browse the repository at this point in the history
Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D155897
  • Loading branch information
clementval committed Jul 22, 2023
1 parent c9d419c commit d4f2416
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions flang/lib/Lower/OpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d4f2416

Please sign in to comment.