|
| 1 | +! Test lowering of Cray pointee references. |
| 2 | +! RUN: flang -fc1 -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s |
| 3 | + |
| 4 | +! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "test_cray_pointers_02"} |
| 5 | +program test_cray_pointers_02 |
| 6 | + implicit none |
| 7 | + |
| 8 | + ! CHECK: fir.call @_QPnone_shared() fastmath<contract> : () -> () |
| 9 | + ! CHECK: fir.call @_QPnone_private() fastmath<contract> : () -> () |
| 10 | + ! CHECK: fir.call @_QPnone_firstprivate() fastmath<contract> : () -> () |
| 11 | + ! CHECK: fir.call @_QPprivate_shared() fastmath<contract> : () -> () |
| 12 | + ! CHECK: fir.call @_QPprivate_firstprivate() fastmath<contract> : () -> () |
| 13 | + ! CHECK: fir.call @_QPfirstprivate_shared() fastmath<contract> : () -> () |
| 14 | + ! CHECK: fir.call @_QPfirstprivate_private() fastmath<contract> : () -> () |
| 15 | + call none_shared() |
| 16 | + call none_private() |
| 17 | + call none_firstprivate() |
| 18 | + call private_shared() |
| 19 | + call private_firstprivate() |
| 20 | + call firstprivate_shared() |
| 21 | + call firstprivate_private() |
| 22 | + ! CHECK: return |
| 23 | + ! CHECK: } |
| 24 | +end program test_cray_pointers_02 |
| 25 | + |
| 26 | +! CHECK-LABEL: func.func @_QPnone_shared() |
| 27 | +subroutine none_shared() |
| 28 | + implicit none |
| 29 | + integer var(*) |
| 30 | + pointer(ivar,var) |
| 31 | + integer pointee(8) |
| 32 | + |
| 33 | + pointee(1) = 42 |
| 34 | + ivar = loc(pointee) |
| 35 | + |
| 36 | + !$omp parallel num_threads(1) default(none) shared(ivar) |
| 37 | + ! CHECK: omp.parallel |
| 38 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 39 | + ! CHECK: {{.*}} = arith.divsi |
| 40 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 41 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 42 | + var(1) = var(1) / 2 |
| 43 | + print '(A24,I6)', 'none_shared', var(1) |
| 44 | + !$omp end parallel |
| 45 | + ! CHECK: return |
| 46 | +end subroutine |
| 47 | + |
| 48 | +! CHECK-LABEL: func.func @_QPnone_private() |
| 49 | +subroutine none_private() |
| 50 | + implicit none |
| 51 | + integer var(*) |
| 52 | + pointer(ivar,var) |
| 53 | + integer pointee(8) |
| 54 | + |
| 55 | + pointee(1) = 42 |
| 56 | + ivar = loc(pointee) |
| 57 | + |
| 58 | + !$omp parallel num_threads(1) default(none) private(ivar) shared(pointee) |
| 59 | + ! CHECK: omp.parallel |
| 60 | + ivar = loc(pointee) |
| 61 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 62 | + ! CHECK: {{.*}} = arith.addi |
| 63 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 64 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 65 | + var(1) = var(1) + 2 |
| 66 | + print '(A24,I6)', 'none_private', var(1) |
| 67 | + !$omp end parallel |
| 68 | + ! CHECK: return |
| 69 | +end subroutine |
| 70 | + |
| 71 | +! CHECK-LABEL: func.func @_QPnone_firstprivate() |
| 72 | +subroutine none_firstprivate() |
| 73 | + implicit none |
| 74 | + integer var(*) |
| 75 | + pointer(ivar,var) |
| 76 | + integer pointee(8) |
| 77 | + |
| 78 | + pointee(1) = 42 |
| 79 | + ivar = loc(pointee) |
| 80 | + |
| 81 | + !$omp parallel num_threads(1) default(none) firstprivate(ivar) |
| 82 | + ! CHECK: omp.parallel |
| 83 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 84 | + ! CHECK: {{.*}} = arith.muli |
| 85 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 86 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 87 | + var(1) = var(1) * 2 |
| 88 | + print '(A24,I6)', 'none_firstprivate', var(1) |
| 89 | + !$omp end parallel |
| 90 | + ! CHECK: return |
| 91 | +end subroutine |
| 92 | + |
| 93 | +! CHECK-LABEL: func.func @_QPprivate_shared() |
| 94 | +subroutine private_shared() |
| 95 | + implicit none |
| 96 | + integer var(*) |
| 97 | + pointer(ivar,var) |
| 98 | + integer pointee(8) |
| 99 | + |
| 100 | + pointee(1) = 42 |
| 101 | + ivar = loc(pointee) |
| 102 | + |
| 103 | + !$omp parallel num_threads(1) default(private) shared(ivar) |
| 104 | + ! CHECK: omp.parallel |
| 105 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 106 | + ! CHECK: {{.*}} = math.ipowi |
| 107 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 108 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 109 | + var(1) = var(1) ** 2 |
| 110 | + print '(A24,I6)', 'private_shared', var(1) |
| 111 | + !$omp end parallel |
| 112 | + ! CHECK: return |
| 113 | +end subroutine |
| 114 | + |
| 115 | +! CHECK-LABEL: func.func @_QPprivate_firstprivate() |
| 116 | +subroutine private_firstprivate() |
| 117 | + implicit none |
| 118 | + integer var(*) |
| 119 | + pointer(ivar,var) |
| 120 | + integer pointee(8) |
| 121 | + |
| 122 | + pointee(1) = 42 |
| 123 | + ivar = loc(pointee) |
| 124 | + |
| 125 | + !$omp parallel num_threads(1) default(private) firstprivate(ivar) |
| 126 | + ! CHECK: omp.parallel |
| 127 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 128 | + ! CHECK: {{.*}} = arith.subi |
| 129 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 130 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 131 | + var(1) = var(1) - 2 |
| 132 | + print '(A24,I6)', 'private_firstprivate', var(1) |
| 133 | + !$omp end parallel |
| 134 | + ! CHECK: return |
| 135 | +end subroutine |
| 136 | + |
| 137 | +! CHECK-LABEL: func.func @_QPfirstprivate_shared() |
| 138 | +subroutine firstprivate_shared() |
| 139 | + implicit none |
| 140 | + integer var(*) |
| 141 | + pointer(ivar,var) |
| 142 | + integer pointee(8) |
| 143 | + |
| 144 | + pointee(1) = 42 |
| 145 | + ivar = loc(pointee) |
| 146 | + |
| 147 | + !$omp parallel num_threads(1) default(firstprivate) shared(ivar) |
| 148 | + ! CHECK: omp.parallel |
| 149 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 150 | + ! CHECK: {{.*}} = arith.divsi |
| 151 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 152 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 153 | + var(1) = var(1) / 2 |
| 154 | + print '(A24,I6)', 'firstprivate_shared', var(1) |
| 155 | + !$omp end parallel |
| 156 | + ! CHECK: return |
| 157 | +end subroutine |
| 158 | + |
| 159 | +! CHECK-LABEL: func.func @_QPfirstprivate_private() |
| 160 | +subroutine firstprivate_private() |
| 161 | + implicit none |
| 162 | + integer var(*) |
| 163 | + pointer(ivar,var) |
| 164 | + integer pointee(8) |
| 165 | + |
| 166 | + pointee(1) = 42 |
| 167 | + ivar = loc(pointee) |
| 168 | + |
| 169 | + !$omp parallel num_threads(1) default(firstprivate) private(ivar) shared(pointee) |
| 170 | + ! CHECK: omp.parallel |
| 171 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 172 | + ! CHECK: {{.*}} = math.ipowi |
| 173 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 174 | + ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () |
| 175 | + ivar = loc(pointee) |
| 176 | + var(1) = var(1) ** 2 |
| 177 | + print '(A24,I6)', 'firstprivate_private', var(1) |
| 178 | + !$omp end parallel |
| 179 | + ! CHECK: return |
| 180 | +end subroutine |
0 commit comments