diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index d46c0c54ee460..a0d10847ea50b 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -1481,6 +1481,8 @@ genACCUpdateOp(Fortran::lower::AbstractConverter &converter, genDataOperandOperations( deviceClause->v, converter, semanticsContext, stmtCtx, dataClauseOperands, mlir::acc::DataClause::acc_update_device, false); + } else if (std::get_if(&clause.u)) { + addIfPresentAttr = true; } } diff --git a/flang/test/Lower/OpenACC/acc-update.f90 b/flang/test/Lower/OpenACC/acc-update.f90 index ee02371e2d4f6..ac25cb12a1ffe 100644 --- a/flang/test/Lower/OpenACC/acc-update.f90 +++ b/flang/test/Lower/OpenACC/acc-update.f90 @@ -14,6 +14,11 @@ subroutine acc_update !$acc update host(a) ! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = 17 : i64, name = "a", structured = false} ! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref>){{$}} +! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {name = "a", structured = false} + + !$acc update host(a) if_present +! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref> {dataClause = 17 : i64, name = "a", structured = false} +! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref>) attributes {ifPresent}{{$}} ! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref>) {name = "a", structured = false} !$acc update host(a) if(.true.)