Skip to content

[Flang][OpenMP] Fix lastprivate store issue #92777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
auto ifOp = firOpBuilder.create<fir::IfOp>(loc, cmpOp, /*else*/ false);
firOpBuilder.setInsertionPointToStart(&ifOp.getThenRegion().front());
assert(loopIV && "loopIV was not set");
firOpBuilder.create<fir::StoreOp>(loopOp.getLoc(), v, loopIV);
firOpBuilder.createStoreWithConvert(loc, v, loopIV);
lastPrivIP = firOpBuilder.saveInsertionPoint();
} else if (mlir::isa<mlir::omp::SectionsOp>(op)) {
// Already handled by genOMP()
Expand Down
19 changes: 19 additions & 0 deletions flang/test/Lower/OpenMP/lastprivate-iv.f90
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,22 @@ subroutine lastprivate_iv_dec()
end do
!$omp end do
end subroutine


!CHECK-LABEL: @_QPlastprivate_iv_i1
subroutine lastprivate_iv_i1
integer*1 :: i1
i1=0
!CHECK: omp.wsloop
!CHECK: omp.loop_nest
!CHECK: fir.if %{{.*}} {
!CHECK: %[[I8_VAL:.*]] = fir.convert %{{.*}} : (i32) -> i8
!CHECK: fir.store %[[I8_VAL]] to %[[IV:.*]]#1 : !fir.ref<i8>
!CHECK: %[[IV_VAL:.*]] = fir.load %[[IV]]#0 : !fir.ref<i8>
!CHECK: hlfir.assign %[[IV_VAL]] to %{{.*}}#0 temporary_lhs : i8, !fir.ref<i8>
!CHECK: }
!$omp do lastprivate(i1)
do i1=1,8
enddo
!$omp end do
end subroutine
Loading