File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -199,12 +199,12 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
199
199
for (const omp::Clause &clause : clauses) {
200
200
if (clause.id != llvm::omp::OMPC_lastprivate)
201
201
continue ;
202
- // TODO: Add lastprivate support for simd construct
203
- if ( mlir::isa<mlir::omp::WsloopOp >(op)) {
202
+ if (mlir::isa<mlir::omp::WsloopOp>(op) or
203
+ mlir::isa<mlir::omp::SimdOp >(op)) {
204
204
// Update the original variable just before exiting the worksharing
205
205
// loop. Conversion as follows:
206
206
//
207
- // omp.wsloop { omp.wsloop {
207
+ // omp.wsloop / omp.simd { omp.wsloop / omp.simd {
208
208
// omp.loop_nest { omp.loop_nest {
209
209
// ... ...
210
210
// store ===> store
Original file line number Diff line number Diff line change @@ -182,3 +182,30 @@ subroutine simd_with_collapse_clause(n)
182
182
end do
183
183
! $OMP END SIMD
184
184
end subroutine
185
+
186
+ ! CHECK: func.func @_QPlastprivate_with_simd() {
187
+ subroutine lastprivate_with_simd
188
+
189
+ ! CHECK: %[[VAR_SUM:.*]] = fir.alloca f32 {bindc_name = "sum", uniq_name = "_QFlastprivate_with_simdEsum"}
190
+ ! CHECK: %[[VAR_SUM_DECLARE:.*]]:2 = hlfir.declare %[[VAR_SUM]] {{.*}}
191
+ ! CHECK: %[[VAR_SUM_PINNED:.*]] = fir.alloca f32 {bindc_name = "sum", pinned, uniq_name = "_QFlastprivate_with_simdEsum"}
192
+ ! CHECK: %[[VAR_SUM_PINNED_DECLARE:.*]]:2 = hlfir.declare %[[VAR_SUM_PINNED]] {{.*}}
193
+ implicit none
194
+ integer :: i
195
+ real :: sum
196
+
197
+ ! CHECK: omp.simd {
198
+ ! CHECK: omp.loop_nest (%[[ARG:.*]]) : i32 = ({{.*}} to ({{.*}}) inclusive step ({{.*}}) {
199
+ ! CHECK: %[[ADD_RESULT:.*]] = arith.addi {{.*}}
200
+ ! CHECK: %[[ADD_RESULT_CONVERT:.*]] = fir.convert %[[ADD_RESULT]] : (i32) -> f32
201
+ ! CHECK: hlfir.assign %[[ADD_RESULT_CONVERT]] to %[[VAR_SUM_PINNED_DECLARE]]#0 : f32, !fir.ref<f32>
202
+ ! $omp simd lastprivate(sum)
203
+ do i = 1 , 100
204
+ sum = i + 1
205
+ end do
206
+ ! CHECK: %[[SELECT_RESULT:.*]] = arith.select {{.*}}, {{.*}}, {{.*}} : i1
207
+ ! CHECK: fir.if %[[SELECT_RESULT]] {
208
+ ! CHECK: %[[LOADED_SUM:.*]] = fir.load %[[VAR_SUM_PINNED_DECLARE]]#0 : !fir.ref<f32>
209
+ ! CHECK: hlfir.assign %[[LOADED_SUM]] to %[[VAR_SUM_DECLARE]]#0 temporary_lhs : f32, !fir.ref<f32>
210
+ ! CHECK: }
211
+ end subroutine
You can’t perform that action at this time.
0 commit comments