1+ ! Fails until we update the pass to use the `fir.do_concurrent` op.
2+
13! Tests mapping of a `do concurrent` loop with multiple iteration ranges.
24
35! RUN: split-file %s %t
46
57! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host %t/multi_range.f90 -o - \
6- ! RUN: | FileCheck %s
8+ ! RUN: | FileCheck %s --check-prefixes=HOST,COMMON
9+
10+ ! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=device %t/multi_range.f90 -o - \
11+ ! RUN: | FileCheck %s --check-prefixes=DEVICE,COMMON
712
813!- -- multi_range.f90
914program main
@@ -17,56 +22,75 @@ program main
1722 end do
1823end
1924
20- ! CHECK: func.func @_QQmain
25+ ! COMMON: func.func @_QQmain
26+
27+ ! COMMON: %[[C3:.*]] = arith.constant 3 : i32
28+ ! COMMON: %[[LB_I:.*]] = fir.convert %[[C3]] : (i32) -> index
29+ ! COMMON: %[[C20:.*]] = arith.constant 20 : i32
30+ ! COMMON: %[[UB_I:.*]] = fir.convert %[[C20]] : (i32) -> index
31+ ! COMMON: %[[STEP_I:.*]] = arith.constant 1 : index
32+
33+ ! COMMON: %[[C5:.*]] = arith.constant 5 : i32
34+ ! COMMON: %[[LB_J:.*]] = fir.convert %[[C5]] : (i32) -> index
35+ ! COMMON: %[[C40:.*]] = arith.constant 40 : i32
36+ ! COMMON: %[[UB_J:.*]] = fir.convert %[[C40]] : (i32) -> index
37+ ! COMMON: %[[STEP_J:.*]] = arith.constant 1 : index
38+
39+ ! COMMON: %[[C7:.*]] = arith.constant 7 : i32
40+ ! COMMON: %[[LB_K:.*]] = fir.convert %[[C7]] : (i32) -> index
41+ ! COMMON: %[[C60:.*]] = arith.constant 60 : i32
42+ ! COMMON: %[[UB_K:.*]] = fir.convert %[[C60]] : (i32) -> index
43+ ! COMMON: %[[STEP_K:.*]] = arith.constant 1 : index
44+
45+ ! DEVICE: omp.target host_eval(
46+ ! DEVICE-SAME: %[[LB_I]] -> %[[LB_I:[[:alnum:]]+]],
47+ ! DEVICE-SAME: %[[UB_I]] -> %[[UB_I:[[:alnum:]]+]],
48+ ! DEVICE-SAME: %[[STEP_I]] -> %[[STEP_I:[[:alnum:]]+]],
49+ ! DEVICE-SAME: %[[LB_J]] -> %[[LB_J:[[:alnum:]]+]],
50+ ! DEVICE-SAME: %[[UB_J]] -> %[[UB_J:[[:alnum:]]+]],
51+ ! DEVICE-SAME: %[[STEP_J]] -> %[[STEP_J:[[:alnum:]]+]],
52+ ! DEVICE-SAME: %[[LB_K]] -> %[[LB_K:[[:alnum:]]+]],
53+ ! DEVICE-SAME: %[[UB_K]] -> %[[UB_K:[[:alnum:]]+]],
54+ ! DEVICE-SAME: %[[STEP_K]] -> %[[STEP_K:[[:alnum:]]+]] :
55+ ! DEVICE-SAME: index, index, index, index, index, index, index, index, index)
2156
22- ! CHECK: %[[C3:.*]] = arith.constant 3 : i32
23- ! CHECK: %[[LB_I:.*]] = fir.convert %[[C3]] : (i32) -> index
24- ! CHECK: %[[C20:.*]] = arith.constant 20 : i32
25- ! CHECK: %[[UB_I:.*]] = fir.convert %[[C20]] : (i32) -> index
26- ! CHECK: %[[STEP_I:.*]] = arith.constant 1 : index
57+ ! DEVICE: omp.teams
2758
28- ! CHECK: %[[C5:.*]] = arith.constant 5 : i32
29- ! CHECK: %[[LB_J:.*]] = fir.convert %[[C5]] : (i32) -> index
30- ! CHECK: %[[C40:.*]] = arith.constant 40 : i32
31- ! CHECK: %[[UB_J:.*]] = fir.convert %[[C40]] : (i32) -> index
32- ! CHECK: %[[STEP_J:.*]] = arith.constant 1 : index
59+ ! HOST-NOT: omp.target
60+ ! HOST-NOT: omp.teams
3361
34- ! CHECK: %[[C7:.*]] = arith.constant 7 : i32
35- ! CHECK: %[[LB_K:.*]] = fir.convert %[[C7]] : (i32) -> index
36- ! CHECK: %[[C60:.*]] = arith.constant 60 : i32
37- ! CHECK: %[[UB_K:.*]] = fir.convert %[[C60]] : (i32) -> index
38- ! CHECK: %[[STEP_K:.*]] = arith.constant 1 : index
62+ ! COMMON: omp.parallel {
3963
40- ! CHECK: omp.parallel {
64+ ! COMMON-NEXT: %[[ITER_VAR_I:.*]] = fir.alloca i32 {bindc_name = "i"}
65+ ! COMMON-NEXT: %[[BINDING_I:.*]]:2 = hlfir.declare %[[ITER_VAR_I]] {uniq_name = "_QFEi"}
4166
42- ! CHECK -NEXT: %[[ITER_VAR_I :.*]] = fir.alloca i32 {bindc_name = "i "}
43- ! CHECK -NEXT: %[[BINDING_I :.*]]:2 = hlfir.declare %[[ITER_VAR_I ]] {uniq_name = "_QFEi "}
67+ ! COMMON -NEXT: %[[ITER_VAR_J :.*]] = fir.alloca i32 {bindc_name = "j "}
68+ ! COMMON -NEXT: %[[BINDING_J :.*]]:2 = hlfir.declare %[[ITER_VAR_J ]] {uniq_name = "_QFEj "}
4469
45- ! CHECK -NEXT: %[[ITER_VAR_J :.*]] = fir.alloca i32 {bindc_name = "j "}
46- ! CHECK -NEXT: %[[BINDING_J :.*]]:2 = hlfir.declare %[[ITER_VAR_J ]] {uniq_name = "_QFEj "}
70+ ! COMMON -NEXT: %[[ITER_VAR_K :.*]] = fir.alloca i32 {bindc_name = "k "}
71+ ! COMMON -NEXT: %[[BINDING_K :.*]]:2 = hlfir.declare %[[ITER_VAR_K ]] {uniq_name = "_QFEk "}
4772
48- ! CHECK-NEXT: %[[ITER_VAR_K:.*]] = fir.alloca i32 {bindc_name = "k"}
49- ! CHECK-NEXT: %[[BINDING_K:.*]]:2 = hlfir.declare %[[ITER_VAR_K]] {uniq_name = "_QFEk"}
73+ ! DEVICE: omp.distribute
5074
51- ! CHECK : omp.wsloop {
52- ! CHECK -NEXT: omp.loop_nest
53- ! CHECK -SAME: (%[[ARG0:[^[:space:]]+]], %[[ARG1:[^[:space:]]+]], %[[ARG2:[^[:space:]]+]])
54- ! CHECK -SAME: : index = (%[[LB_I]], %[[LB_J]], %[[LB_K]])
55- ! CHECK -SAME: to (%[[UB_I]], %[[UB_J]], %[[UB_K]]) inclusive
56- ! CHECK -SAME: step (%[[STEP_I]], %[[STEP_J]], %[[STEP_K]]) {
75+ ! COMMON : omp.wsloop {
76+ ! COMMON -NEXT: omp.loop_nest
77+ ! COMMON -SAME: (%[[ARG0:[^[:space:]]+]], %[[ARG1:[^[:space:]]+]], %[[ARG2:[^[:space:]]+]])
78+ ! COMMON -SAME: : index = (%[[LB_I]], %[[LB_J]], %[[LB_K]])
79+ ! COMMON -SAME: to (%[[UB_I]], %[[UB_J]], %[[UB_K]]) inclusive
80+ ! COMMON -SAME: step (%[[STEP_I]], %[[STEP_J]], %[[STEP_K]]) {
5781
58- ! CHECK -NEXT: %[[IV_IDX_I:.*]] = fir.convert %[[ARG0]]
59- ! CHECK -NEXT: fir.store %[[IV_IDX_I]] to %[[BINDING_I]]#0
82+ ! COMMON -NEXT: %[[IV_IDX_I:.*]] = fir.convert %[[ARG0]]
83+ ! COMMON -NEXT: fir.store %[[IV_IDX_I]] to %[[BINDING_I]]#0
6084
61- ! CHECK -NEXT: %[[IV_IDX_J:.*]] = fir.convert %[[ARG1]]
62- ! CHECK -NEXT: fir.store %[[IV_IDX_J]] to %[[BINDING_J]]#0
85+ ! COMMON -NEXT: %[[IV_IDX_J:.*]] = fir.convert %[[ARG1]]
86+ ! COMMON -NEXT: fir.store %[[IV_IDX_J]] to %[[BINDING_J]]#0
6387
64- ! CHECK -NEXT: %[[IV_IDX_K:.*]] = fir.convert %[[ARG2]]
65- ! CHECK -NEXT: fir.store %[[IV_IDX_K]] to %[[BINDING_K]]#0
88+ ! COMMON -NEXT: %[[IV_IDX_K:.*]] = fir.convert %[[ARG2]]
89+ ! COMMON -NEXT: fir.store %[[IV_IDX_K]] to %[[BINDING_K]]#0
6690
67- ! CHECK : omp.yield
68- ! CHECK -NEXT: }
69- ! CHECK -NEXT: }
91+ ! COMMON : omp.yield
92+ ! COMMON -NEXT: }
93+ ! COMMON -NEXT: }
7094
71- ! CHECK -NEXT: omp.terminator
72- ! CHECK -NEXT: }
95+ ! HOST -NEXT: omp.terminator
96+ ! HOST -NEXT: }
0 commit comments