File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -190,12 +190,12 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
190190 for (const omp::Clause &clause : clauses) {
191191 if (clause.id != llvm::omp::OMPC_lastprivate)
192192 continue ;
193- // TODO: Add lastprivate support for simd construct
194- if ( mlir::isa<mlir::omp::WsloopOp >(op)) {
193+ if (mlir::isa<mlir::omp::WsloopOp>(op) ||
194+ mlir::isa<mlir::omp::SimdOp >(op)) {
195195 // Update the original variable just before exiting the worksharing
196196 // loop. Conversion as follows:
197197 //
198- // omp.wsloop { omp.wsloop {
198+ // omp.wsloop / omp.simd { omp.wsloop / omp.simd {
199199 // omp.loop_nest { omp.loop_nest {
200200 // ... ...
201201 // store ===> store
Original file line number Diff line number Diff line change @@ -241,3 +241,36 @@ subroutine simd_with_nontemporal_clause(n)
241241 end do
242242 ! $OMP END SIMD
243243end subroutine
244+
245+ ! CHECK-LABEL: func.func @_QPlastprivate_with_simd() {
246+ subroutine lastprivate_with_simd
247+
248+ ! CHECK: %[[VAR_SUM:.*]] = fir.alloca f32 {bindc_name = "sum", uniq_name = "_QFlastprivate_with_simdEsum"}
249+ ! CHECK: %[[VAR_SUM_DECLARE:.*]]:2 = hlfir.declare %[[VAR_SUM]] {{.*}}
250+ ! CHECK: %[[VAR_SUM_PINNED:.*]] = fir.alloca f32 {bindc_name = "sum", pinned, uniq_name = "_QFlastprivate_with_simdEsum"}
251+ ! CHECK: %[[VAR_SUM_PINNED_DECLARE:.*]]:2 = hlfir.declare %[[VAR_SUM_PINNED]] {{.*}}
252+
253+ implicit none
254+ integer :: i
255+ real :: sum
256+
257+
258+ ! CHECK: omp.simd {
259+ ! CHECK: omp.loop_nest (%[[ARG:.*]]) : i32 = ({{.*}} to ({{.*}}) inclusive step ({{.*}}) {
260+ ! CHECK: %[[ADD_RESULT:.*]] = arith.addi {{.*}}
261+ ! CHECK: %[[ADD_RESULT_CONVERT:.*]] = fir.convert %[[ADD_RESULT]] : (i32) -> f32
262+ ! CHECK: hlfir.assign %[[ADD_RESULT_CONVERT]] to %[[VAR_SUM_PINNED_DECLARE]]#0 : f32, !fir.ref<f32>
263+ ! CHECK: %[[SELECT_RESULT:.*]] = arith.select {{.*}}, {{.*}}, {{.*}} : i1
264+ ! CHECK: fir.if %[[SELECT_RESULT]] {
265+ ! CHECK: %[[LOADED_SUM:.*]] = fir.load %[[VAR_SUM_PINNED_DECLARE]]#0 : !fir.ref<f32>
266+ ! CHECK: hlfir.assign %[[LOADED_SUM]] to %[[VAR_SUM_DECLARE]]#0 : f32, !fir.ref<f32>
267+ ! CHECK: }
268+ ! CHECK: omp.yield
269+ ! CHECK: }
270+ ! CHECK: omp.terminator
271+ ! CHECK: }
272+ ! $omp simd lastprivate(sum)
273+ do i = 1 , 100
274+ sum = i + 1
275+ end do
276+ end subroutine
You can’t perform that action at this time.
0 commit comments