197 lines · plain
1// RUN: fir-opt --split-input-file --verify-diagnostics --omp-simd-only %s | FileCheck %s2 3// Check that simd operations are not removed and rewritten, but all the other OpenMP ops are.4// Tests the logic in flang/lib/Optimizer/OpenMP/SimdOnly.cpp5 6// CHECK: omp.private7// CHECK-LABEL: func.func @simd8omp.private {type = private} @_QFEi_private_i32 : i329func.func @simd(%arg0: i32, %arg1: !fir.ref<i32>, %arg2: !fir.ref<i32>) {10 %c1_i32 = arith.constant 1 : i3211 %c100000_i32 = arith.constant 100000 : i3212 // CHECK: omp.simd private13 omp.simd private(@_QFEi_private_i32 %arg2 -> %arg3 : !fir.ref<i32>) {14 // CHECK: omp.loop_nest15 omp.loop_nest (%arg4) : i32 = (%c1_i32) to (%c100000_i32) inclusive step (%c1_i32) {16 // CHECK: fir.store17 fir.store %arg0 to %arg1 : !fir.ref<i32>18 // CHECK: omp.yield19 omp.yield20 }21 }22 return23}24 25// -----26 27// CHECK-LABEL: func.func @simd_composite28func.func @simd_composite(%arg0: i32, %arg1: !fir.ref<i32>) {29 %c1_i32 = arith.constant 1 : i3230 %c100000_i32 = arith.constant 100000 : i3231 // CHECK-NOT: omp.parallel32 omp.parallel {33 // CHECK-NOT: omp.wsloop34 omp.wsloop {35 // CHECK: omp.simd36 omp.simd {37 // CHECK: omp.loop_nest38 omp.loop_nest (%arg3) : i32 = (%c1_i32) to (%c100000_i32) inclusive step (%c1_i32) {39 // CHECK: fir.store40 fir.store %arg0 to %arg1 : !fir.ref<i32>41 // CHECK: omp.yield42 omp.yield43 }44 // CHECK-NOT: {omp.composite}45 } {omp.composite}46 } {omp.composite}47 omp.terminator48 }49 return50}51 52// -----53 54// CHECK-NOT: omp.private55// CHECK-LABEL: func.func @parallel56omp.private {type = private} @_QFEi_private_i32 : i3257func.func @parallel(%arg0: i32, %arg1: !fir.ref<i32>) {58 %c1 = arith.constant 1 : index59 %c1_i32 = arith.constant 1 : i3260 %c100000_i32 = arith.constant 100000 : i3261 // CHECK-NOT: omp.parallel62 omp.parallel private(@_QFEi_private_i32 %arg1 -> %arg3 : !fir.ref<i32>) {63 // CHECK: fir.convert64 %15 = fir.convert %c1_i32 : (i32) -> index65 // CHECK: fir.convert66 %16 = fir.convert %c100000_i32 : (i32) -> index67 // CHECK: fir.do_loop68 %18 = fir.do_loop %arg4 = %15 to %16 step %c1 iter_args(%arg2 = %arg0) -> (i32) {69 // CHECK: fir.store70 fir.store %arg0 to %arg1 : !fir.ref<i32>71 fir.result %arg2 : i3272 }73 // CHECK-NOT: omp.terminator74 omp.terminator75 }76 return77}78 79// -----80 81// CHECK-LABEL: func.func @target_map(82// CHECK-SAME: %[[ARG_0:.*]]: i32, %[[ARG_1:.*]]: !fir.ref<i32>83func.func @target_map(%arg5: i32, %arg6: !fir.ref<i32>) {84 // CHECK-NOT: omp.map.info85 %3 = omp.map.info var_ptr(%arg6 : !fir.ref<i32>, i32) map_clauses(implicit) capture(ByCopy) -> !fir.ref<i32>86 // CHECK-NOT: omp.target87 omp.target map_entries(%3 -> %arg0 : !fir.ref<i32>) {88 // CHECK: arith.constant89 %c1_i32 = arith.constant 1 : i3290 // CHECK: fir.store %c1_i32 to %[[ARG_1]]91 fir.store %c1_i32 to %arg0 : !fir.ref<i32>92 // CHECK-NOT: omp.terminator93 omp.terminator94 }95 return96}97 98// -----99 100// CHECK-LABEL: func.func @teams101func.func @teams(%arg0: i32, %arg1: !fir.ref<i32>) {102 // CHECK-NOT: omp.teams103 omp.teams {104 // CHECK: fir.store105 fir.store %arg0 to %arg1 : !fir.ref<i32>106 // CHECK-NOT: omp.terminator107 omp.terminator108 }109 return110}111 112// -----113 114// CHECK-LABEL: func.func @distribute_simd115func.func @distribute_simd(%arg0: i32, %arg1: !fir.ref<i32>) {116 %c1_i32 = arith.constant 1 : i32117 %c100000_i32 = arith.constant 100000 : i32118 // CHECK-NOT: omp.distribute119 omp.distribute {120 // CHECK: omp.simd121 omp.simd {122 // CHECK: omp.loop_nest123 omp.loop_nest (%arg3) : i32 = (%c1_i32) to (%c100000_i32) inclusive step (%c1_i32) {124 // CHECK: fir.store125 fir.store %arg0 to %arg1 : !fir.ref<i32>126 // CHECK: omp.yield127 omp.yield128 }129 // CHECK-NOT: {omp.composite}130 } {omp.composite}131 // CHECK-NOT: {omp.composite}132 } {omp.composite}133 return134}135 136// -----137 138// CHECK-LABEL: func.func @threadprivate(139// CHECK-SAME: %[[ARG_0:.*]]: i32, %[[ARG_1:.*]]: !fir.ref<i32>140func.func @threadprivate(%arg0: i32, %arg1: !fir.ref<i32>) {141 // CHECK-NOT: omp.threadprivate142 %1 = omp.threadprivate %arg1 : !fir.ref<i32> -> !fir.ref<i32>143 // CHECK: fir.store %[[ARG_0]] to %[[ARG_1]]144 fir.store %arg0 to %1 : !fir.ref<i32>145 return146}147 148// -----149 150// CHECK-LABEL: func.func @multi_block(151// CHECK-SAME: %[[ARG_0:.*]]: i32, %[[ARG_1:.*]]: !fir.ref<i32>, %[[ARG_3:.*]]: i1152func.func @multi_block(%funcArg0: i32, %funcArg1: !fir.ref<i32>, %6: i1) {153 %false = arith.constant false154 %c0_i32 = arith.constant 0 : i32155 // CHECK-NOT: omp.parallel156 omp.parallel {157 // CHECK: cf.cond_br %[[ARG_3]], ^[[BB1:.*]], ^[[BB2:.*]]158 cf.cond_br %6, ^bb1, ^bb2159 // CHECK: ^[[BB1]]160 ^bb1: // pred: ^bb0161 // CHECK: fir.call162 fir.call @_FortranAStopStatement(%c0_i32, %false, %false) fastmath<contract> : (i32, i1, i1) -> ()163 // CHECK-NOT: omp.terminator164 omp.terminator165 // CHECK: ^[[BB2]]166 ^bb2: // pred: ^bb0167 // CHECK: fir.store168 fir.store %funcArg0 to %funcArg1 : !fir.ref<i32>169 // CHECK-NOT: omp.terminator170 omp.terminator171 }172 return173}174 175// -----176 177// CHECK-LABEL: func.func @map_info(178// CHECK-SAME: %[[ARG_0:.*]]: i32, %[[ARG_1:.*]]: !fir.ref<i32>179func.func @map_info(%funcArg0: i32, %funcArg1: !fir.ref<i32>) {180 %c1 = arith.constant 1 : index181 // CHECK-NOT: omp.map.bounds182 %1 = omp.map.bounds lower_bound(%c1 : index) upper_bound(%c1 : index) extent(%c1 : index) stride(%c1 : index) start_idx(%c1 : index)183 // CHECK-NOT: omp.map.info184 %13 = omp.map.info var_ptr(%funcArg1 : !fir.ref<i32>, i32) map_clauses(to) capture(ByRef) bounds(%1) -> !fir.ref<i32>185 // CHECK-NOT: omp.target186 omp.target map_entries(%13 -> %arg3 : !fir.ref<i32>) {187 %c1_i32 = arith.constant 1 : i32188 // CHECK: fir.store %c1_i32 to %[[ARG_1]]189 fir.store %c1_i32 to %arg3 : !fir.ref<i32>190 // CHECK-NOT: omp.terminator191 omp.terminator192 }193 // CHECK-NOT: omp.map.info194 %18 = omp.map.info var_ptr(%funcArg1 : !fir.ref<i32>, i32) map_clauses(from) capture(ByRef) bounds(%1) -> !fir.ref<i32>195 return196}197