[flang-commits] [flang] 7cee61c - [Flang][OpenMP] Fix lastprivate store issue (#92777)
via flang-commits
flang-commits at lists.llvm.org
Tue May 21 02:48:56 PDT 2024
Author: Kiran Chandramohan
Date: 2024-05-21T10:48:52+01:00
New Revision: 7cee61c82f7fe5a563c2781e855c13238c44931f
URL: https://github.com/llvm/llvm-project/commit/7cee61c82f7fe5a563c2781e855c13238c44931f
DIFF: https://github.com/llvm/llvm-project/commit/7cee61c82f7fe5a563c2781e855c13238c44931f.diff
LOG: [Flang][OpenMP] Fix lastprivate store issue (#92777)
Fix an issue where the lastprivate variable type is different from the
type used for the index of the loop.
Fixes #79780
Added:
Modified:
flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
flang/test/Lower/OpenMP/lastprivate-iv.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 84e745f28f974..2bdc523bf3715 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -225,7 +225,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()
diff --git a/flang/test/Lower/OpenMP/lastprivate-iv.f90 b/flang/test/Lower/OpenMP/lastprivate-iv.f90
index 24c20281b9c38..718c9c99370e9 100644
--- a/flang/test/Lower/OpenMP/lastprivate-iv.f90
+++ b/flang/test/Lower/OpenMP/lastprivate-iv.f90
@@ -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
More information about the flang-commits
mailing list