Debian Codegraph @

flang/test/Lower/OpenMP/lastprivate-iv.f90

raw
1 ! Test LASTPRIVATE with iteration variable.
2 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
3
4 !CHECK-LABEL: func @_QPlastprivate_iv_inc
5
6 !CHECK: %[[I2_MEM:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFlastprivate_iv_incEi"}
7 !CHECK: %[[I2:.*]]:2 = hlfir.declare %[[I2_MEM]] {uniq_name = "_QFlastprivate_iv_incEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
8
9 !CHECK: %[[I_MEM:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}}
10 !CHECK: %[[I:.*]]:2 = hlfir.declare %[[I_MEM]] {uniq_name = "_QFlastprivate_iv_incEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
11
12 !CHECK: %[[LB:.*]] = arith.constant 4 : i32
13 !CHECK: %[[UB:.*]] = arith.constant 10 : i32
14 !CHECK: %[[STEP:.*]] = arith.constant 3 : i32
15 !CHECK: omp.wsloop {
16 !CHECK-NEXT: omp.loop_nest (%[[IV:.*]]) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]]) {
17 !CHECK: fir.store %[[IV]] to %[[I]]#1 : !fir.ref<i32>
18 !CHECK: %[[V:.*]] = arith.addi %[[IV]], %[[STEP]] : i32
19 !CHECK: %[[C0:.*]] = arith.constant 0 : i32
20 !CHECK: %[[STEP_NEG:.*]] = arith.cmpi slt, %[[STEP]], %[[C0]] : i32
21 !CHECK: %[[V_LT:.*]] = arith.cmpi slt, %[[V]], %[[UB]] : i32
22 !CHECK: %[[V_GT:.*]] = arith.cmpi sgt, %[[V]], %[[UB]] : i32
23 !CHECK: %[[CMP:.*]] = arith.select %[[STEP_NEG]], %[[V_LT]], %[[V_GT]] : i1
24 !CHECK: fir.if %[[CMP]] {
25 !CHECK: fir.store %[[V]] to %[[I]]#1 : !fir.ref<i32>
26 !CHECK: %[[I_VAL:.*]] = fir.load %[[I]]#0 : !fir.ref<i32>
27 !CHECK: hlfir.assign %[[I_VAL]] to %[[I2]]#0 temporary_lhs : i32, !fir.ref<i32>
28 !CHECK: }
29 !CHECK: omp.yield
30 !CHECK: }
31 !CHECK: omp.terminator
32 !CHECK: }
33 subroutine lastprivate_iv_inc()
34 integer :: i
35
36 !$omp do lastprivate(i)
37 do i = 4, 10, 3
38 end do
39 !$omp end do
40 end subroutine
41
42 !CHECK-LABEL: func @_QPlastprivate_iv_dec
43
44 !CHECK: %[[I2_MEM:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFlastprivate_iv_decEi"}
45 !CHECK: %[[I2:.*]]:2 = hlfir.declare %[[I2_MEM]] {uniq_name = "_QFlastprivate_iv_decEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
46
47 !CHECK: %[[I_MEM:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}}
48 !CHECK: %[[I:.*]]:2 = hlfir.declare %[[I_MEM]] {uniq_name = "_QFlastprivate_iv_decEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
49
50 !CHECK: %[[LB:.*]] = arith.constant 10 : i32
51 !CHECK: %[[UB:.*]] = arith.constant 1 : i32
52 !CHECK: %[[STEP:.*]] = arith.constant -3 : i32
53 !CHECK: omp.wsloop {
54 !CHECK-NEXT: omp.loop_nest (%[[IV:.*]]) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]]) {
55 !CHECK: fir.store %[[IV]] to %[[I]]#1 : !fir.ref<i32>
56 !CHECK: %[[V:.*]] = arith.addi %[[IV]], %[[STEP]] : i32
57 !CHECK: %[[C0:.*]] = arith.constant 0 : i32
58 !CHECK: %[[STEP_NEG:.*]] = arith.cmpi slt, %[[STEP]], %[[C0]] : i32
59 !CHECK: %[[V_LT:.*]] = arith.cmpi slt, %[[V]], %[[UB]] : i32
60 !CHECK: %[[V_GT:.*]] = arith.cmpi sgt, %[[V]], %[[UB]] : i32
61 !CHECK: %[[CMP:.*]] = arith.select %[[STEP_NEG]], %[[V_LT]], %[[V_GT]] : i1
62 !CHECK: fir.if %[[CMP]] {
63 !CHECK: fir.store %[[V]] to %[[I]]#1 : !fir.ref<i32>
64 !CHECK: %[[I_VAL:.*]] = fir.load %[[I]]#0 : !fir.ref<i32>
65 !CHECK: hlfir.assign %[[I_VAL]] to %[[I2]]#0 temporary_lhs : i32, !fir.ref<i32>
66 !CHECK: }
67 !CHECK: omp.yield
68 !CHECK: }
69 !CHECK: omp.terminator
70 !CHECK: }
71 subroutine lastprivate_iv_dec()
72 integer :: i
73
74 !$omp do lastprivate(i)
75 do i = 10, 1, -3
76 end do
77 !$omp end do
78 end subroutine
79
80
81 !CHECK-LABEL: @_QPlastprivate_iv_i1
82 subroutine lastprivate_iv_i1
83 integer*1 :: i1
84 i1=0
85 !CHECK: omp.wsloop
86 !CHECK: omp.loop_nest
87 !CHECK: fir.if %{{.*}} {
88 !CHECK: %[[I8_VAL:.*]] = fir.convert %{{.*}} : (i32) -> i8
89 !CHECK: fir.store %[[I8_VAL]] to %[[IV:.*]]#1 : !fir.ref<i8>
90 !CHECK: %[[IV_VAL:.*]] = fir.load %[[IV]]#0 : !fir.ref<i8>
91 !CHECK: hlfir.assign %[[IV_VAL]] to %{{.*}}#0 temporary_lhs : i8, !fir.ref<i8>
92 !CHECK: }
93 !$omp do lastprivate(i1)
94 do i1=1,8
95 enddo
96 !$omp end do
97 end subroutine