Skip to content

Commit f2031ac

Browse files
committed
[flang][openacc] Lower if_present clause correctly on acc update
The `if_present` clause is modeled as an attribute on the acc.update operation. The lowering was not adding correctly the attribute when the clause was present. This patch update the lowering to add the attribute when needed. Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D150171
1 parent 21508fa commit f2031ac

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

flang/lib/Lower/OpenACC.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,8 @@ genACCUpdateOp(Fortran::lower::AbstractConverter &converter,
14811481
genDataOperandOperations<mlir::acc::UpdateDeviceOp>(
14821482
deviceClause->v, converter, semanticsContext, stmtCtx,
14831483
dataClauseOperands, mlir::acc::DataClause::acc_update_device, false);
1484+
} else if (std::get_if<Fortran::parser::AccClause::IfPresent>(&clause.u)) {
1485+
addIfPresentAttr = true;
14841486
}
14851487
}
14861488

flang/test/Lower/OpenACC/acc-update.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ subroutine acc_update
1414
!$acc update host(a)
1515
! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<10x10xf32>> {dataClause = 17 : i64, name = "a", structured = false}
1616
! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
17+
! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) {name = "a", structured = false}
18+
19+
!$acc update host(a) if_present
20+
! CHECK: %[[DEVPTR_A:.*]] = acc.getdeviceptr varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) -> !fir.ref<!fir.array<10x10xf32>> {dataClause = 17 : i64, name = "a", structured = false}
21+
! CHECK: acc.update dataOperands(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) attributes {ifPresent}{{$}}
1722
! CHECK: acc.update_host accPtr(%[[DEVPTR_A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%{{.*}}, %{{.*}}) to varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) {name = "a", structured = false}
1823

1924
!$acc update host(a) if(.true.)

0 commit comments

Comments
 (0)