@@ -180,14 +180,16 @@ func.func @_QPsimd1(%arg0: !fir.ref<i32> {fir.bindc_name = "n"}, %arg1: !fir.ref
180
180
omp.parallel {
181
181
%1 = fir.alloca i32 {adapt.valuebyref, pinned}
182
182
%2 = fir.load %arg0 : !fir.ref<i32>
183
- omp.simdloop for (%arg2) : i32 = (%c1_i32) to (%2) step (%c1_i32) {
184
- fir.store %arg2 to %1 : !fir.ref<i32>
185
- %3 = fir.load %1 : !fir.ref<i32>
186
- %4 = fir.convert %3 : (i32) -> i64
187
- %5 = arith.subi %4, %c1_i64 : i64
188
- %6 = fir.coordinate_of %arg1, %5 : (!fir.ref<!fir.array<?xi32>>, i64) -> !fir.ref<i32>
189
- fir.store %3 to %6 : !fir.ref<i32>
190
- omp.yield
183
+ omp.simd {
184
+ omp.loop_nest (%arg2) : i32 = (%c1_i32) to (%2) step (%c1_i32) {
185
+ fir.store %arg2 to %1 : !fir.ref<i32>
186
+ %3 = fir.load %1 : !fir.ref<i32>
187
+ %4 = fir.convert %3 : (i32) -> i64
188
+ %5 = arith.subi %4, %c1_i64 : i64
189
+ %6 = fir.coordinate_of %arg1, %5 : (!fir.ref<!fir.array<?xi32>>, i64) -> !fir.ref<i32>
190
+ fir.store %3 to %6 : !fir.ref<i32>
191
+ omp.yield
192
+ }
191
193
}
192
194
omp.terminator
193
195
}
@@ -202,8 +204,8 @@ func.func @_QPsimd1(%arg0: !fir.ref<i32> {fir.bindc_name = "n"}, %arg1: !fir.ref
202
204
// CHECK: %[[ONE_3:.*]] = llvm.mlir.constant(1 : i64) : i64
203
205
// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {pinned} : (i64) -> !llvm.ptr
204
206
// CHECK: %[[N:.*]] = llvm.load %[[N_REF]] : !llvm.ptr -> i32
205
- // CHECK: omp.simdloop
206
- // CHECK-SAME: (%[[I:.*]]) : i32 = (%[[ONE_2]]) to (%[[N]]) step (%[[ONE_2]]) {
207
+ // CHECK: omp.simd {
208
+ // CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%[[ONE_2]]) to (%[[N]]) step (%[[ONE_2]]) {
207
209
// CHECK: llvm.store %[[I]], %[[I_VAR]] : i32, !llvm.ptr
208
210
// CHECK: %[[I1:.*]] = llvm.load %[[I_VAR]] : !llvm.ptr -> i32
209
211
// CHECK: %[[I1_EXT:.*]] = llvm.sext %[[I1]] : i32 to i64
@@ -212,6 +214,7 @@ func.func @_QPsimd1(%arg0: !fir.ref<i32> {fir.bindc_name = "n"}, %arg1: !fir.ref
212
214
// CHECK: llvm.store %[[I1]], %[[ARR_I_REF]] : i32, !llvm.ptr
213
215
// CHECK: omp.yield
214
216
// CHECK: }
217
+ // CHECK: }
215
218
// CHECK: omp.terminator
216
219
// CHECK: }
217
220
// CHECK: llvm.return
@@ -471,55 +474,59 @@ func.func @_QPomp_target() {
471
474
472
475
// -----
473
476
474
- func.func @_QPsimdloop_with_nested_loop () {
477
+ func.func @_QPsimd_with_nested_loop () {
475
478
%0 = fir.alloca i32 {adapt.valuebyref}
476
- %1 = fir.alloca !fir.array<10xi32> {bindc_name = "a", uniq_name = "_QFsimdloop_with_nested_loopEa "}
477
- %2 = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFsimdloop_with_nested_loopEi "}
478
- %3 = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFsimdloop_with_nested_loopEj "}
479
+ %1 = fir.alloca !fir.array<10xi32> {bindc_name = "a", uniq_name = "_QFsimd_with_nested_loopEa "}
480
+ %2 = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFsimd_with_nested_loopEi "}
481
+ %3 = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFsimd_with_nested_loopEj "}
479
482
%c1_i32 = arith.constant 1 : i32
480
483
%c10_i32 = arith.constant 10 : i32
481
484
%c1_i32_0 = arith.constant 1 : i32
482
- omp.simdloop for (%arg0) : i32 = (%c1_i32) to (%c10_i32) inclusive step (%c1_i32_0) {
483
- fir.store %arg0 to %0 : !fir.ref<i32>
484
- %c1_i32_1 = arith.constant 1 : i32
485
- %4 = fir.convert %c1_i32_1 : (i32) -> index
486
- %c10_i32_2 = arith.constant 10 : i32
487
- %5 = fir.convert %c10_i32_2 : (i32) -> index
488
- %c1 = arith.constant 1 : index
489
- %6 = fir.do_loop %arg1 = %4 to %5 step %c1 -> index {
490
- %8 = fir.convert %arg1 : (index) -> i32
491
- fir.store %8 to %3 : !fir.ref<i32>
492
- %9 = fir.load %0 : !fir.ref<i32>
493
- %10 = fir.load %0 : !fir.ref<i32>
494
- %11 = fir.convert %10 : (i32) -> i64
495
- %c1_i64 = arith.constant 1 : i64
496
- %12 = arith.subi %11, %c1_i64 : i64
497
- %13 = fir.coordinate_of %1, %12 : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
498
- fir.store %9 to %13 : !fir.ref<i32>
499
- %14 = arith.addi %arg1, %c1 : index
500
- fir.result %14 : index
485
+ omp.simd {
486
+ omp.loop_nest (%arg0) : i32 = (%c1_i32) to (%c10_i32) inclusive step (%c1_i32_0) {
487
+ fir.store %arg0 to %0 : !fir.ref<i32>
488
+ %c1_i32_1 = arith.constant 1 : i32
489
+ %4 = fir.convert %c1_i32_1 : (i32) -> index
490
+ %c10_i32_2 = arith.constant 10 : i32
491
+ %5 = fir.convert %c10_i32_2 : (i32) -> index
492
+ %c1 = arith.constant 1 : index
493
+ %6 = fir.do_loop %arg1 = %4 to %5 step %c1 -> index {
494
+ %8 = fir.convert %arg1 : (index) -> i32
495
+ fir.store %8 to %3 : !fir.ref<i32>
496
+ %9 = fir.load %0 : !fir.ref<i32>
497
+ %10 = fir.load %0 : !fir.ref<i32>
498
+ %11 = fir.convert %10 : (i32) -> i64
499
+ %c1_i64 = arith.constant 1 : i64
500
+ %12 = arith.subi %11, %c1_i64 : i64
501
+ %13 = fir.coordinate_of %1, %12 : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
502
+ fir.store %9 to %13 : !fir.ref<i32>
503
+ %14 = arith.addi %arg1, %c1 : index
504
+ fir.result %14 : index
505
+ }
506
+ %7 = fir.convert %6 : (index) -> i32
507
+ fir.store %7 to %3 : !fir.ref<i32>
508
+ omp.yield
501
509
}
502
- %7 = fir.convert %6 : (index) -> i32
503
- fir.store %7 to %3 : !fir.ref<i32>
504
- omp.yield
505
510
}
506
511
return
507
512
}
508
513
509
- // CHECK-LABEL: llvm.func @_QPsimdloop_with_nested_loop () {
514
+ // CHECK-LABEL: llvm.func @_QPsimd_with_nested_loop () {
510
515
// CHECK: %[[LOWER:.*]] = llvm.mlir.constant(1 : i32) : i32
511
516
// CHECK: %[[UPPER:.*]] = llvm.mlir.constant(10 : i32) : i32
512
517
// CHECK: %[[STEP:.*]] = llvm.mlir.constant(1 : i32) : i32
513
- // CHECK: omp.simdloop for (%[[CNT:.*]]) : i32 = (%[[LOWER]]) to (%[[UPPER]]) inclusive step (%[[STEP]]) {
514
- // CHECK: llvm.br ^bb1(%[[VAL_1:.*]], %[[VAL_2:.*]] : i64, i64)
515
- // CHECK: ^bb1(%[[VAL_3:.*]]: i64, %[[VAL_4:.*]]: i64):
516
- // CHECK: %[[VAL_5:.*]] = llvm.mlir.constant(0 : index) : i64
517
- // CHECK: %[[VAL_6:.*]] = llvm.icmp "sgt" %[[VAL_4]], %[[VAL_5]] : i64
518
- // CHECK: llvm.cond_br %[[VAL_6]], ^bb2, ^bb3
519
- // CHECK: ^bb2:
520
- // CHECK: llvm.br ^bb1(%[[VAL_7:.*]], %[[VAL_8:.*]] : i64, i64)
521
- // CHECK: ^bb3:
522
- // CHECK: omp.yield
518
+ // CHECK: omp.simd {
519
+ // CHECK-NEXT: omp.loop_nest (%[[CNT:.*]]) : i32 = (%[[LOWER]]) to (%[[UPPER]]) inclusive step (%[[STEP]]) {
520
+ // CHECK: llvm.br ^bb1(%[[VAL_1:.*]], %[[VAL_2:.*]] : i64, i64)
521
+ // CHECK: ^bb1(%[[VAL_3:.*]]: i64, %[[VAL_4:.*]]: i64):
522
+ // CHECK: %[[VAL_5:.*]] = llvm.mlir.constant(0 : index) : i64
523
+ // CHECK: %[[VAL_6:.*]] = llvm.icmp "sgt" %[[VAL_4]], %[[VAL_5]] : i64
524
+ // CHECK: llvm.cond_br %[[VAL_6]], ^bb2, ^bb3
525
+ // CHECK: ^bb2:
526
+ // CHECK: llvm.br ^bb1(%[[VAL_7:.*]], %[[VAL_8:.*]] : i64, i64)
527
+ // CHECK: ^bb3:
528
+ // CHECK: omp.yield
529
+ // CHECK: }
523
530
// CHECK: }
524
531
// CHECK: llvm.return
525
532
// CHECK: }
0 commit comments