162 lines · plain
1! This test checks lowering of stop statement in OpenMP region.2 3! RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s4! RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s5 6 7! CHECK-LABEL: func.func @_QPtest_stop_in_region1() {8! CHECK: omp.parallel {9! CHECK: %[[VAL_0:.*]] = arith.constant 1 : i3210! CHECK: %[[VAL_1:.*]] = arith.constant false11! CHECK: %[[VAL_2:.*]] = arith.constant false12! CHECK: fir.call @_FortranAStopStatement(%[[VAL_0]], %[[VAL_1]], %[[VAL_2]]) {{.*}} : (i32, i1, i1) -> ()13! CHECK-NOT: fir.unreachable14! CHECK: omp.terminator15! CHECK: }16! CHECK: return17! CHECK: }18 19subroutine test_stop_in_region1()20 !$omp parallel21 stop 122 !$omp end parallel23end24 25! CHECK-LABEL: func.func @_QPtest_stop_in_region2() {26! CHECK: %{{.*}} = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFtest_stop_in_region2Ex"}27! CHECK: omp.parallel {28! CHECK: %[[VAL_1:.*]] = arith.constant 1 : i3229! CHECK: %[[VAL_2:.*]] = arith.constant false30! CHECK: %[[VAL_3:.*]] = arith.constant false31! CHECK: fir.call @_FortranAStopStatement(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]]) {{.*}} : (i32, i1, i1) -> ()32! CHECK: omp.terminator33! CHECK: }34! CHECK: return35! CHECK: }36 37subroutine test_stop_in_region2()38 integer :: x39 !$omp parallel40 stop 141 x = 242 !$omp end parallel43end44 45! CHECK-LABEL: func.func @_QPtest_stop_in_region3() {46! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFtest_stop_in_region3Ex"}47! CHECK: %[[VAL_0_DECL:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest_stop_in_region3Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)48! CHECK: omp.parallel {49! CHECK: %[[VAL_1:.*]] = arith.constant 3 : i3250! CHECK: hlfir.assign %[[VAL_1]] to %[[VAL_0_DECL]]#0 : i32, !fir.ref<i32>51! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0_DECL]]#0 : !fir.ref<i32>52! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i3253! CHECK: %[[VAL_4:.*]] = arith.cmpi sgt, %[[VAL_2]], %[[VAL_3]] : i3254! CHECK: cf.cond_br %[[VAL_4]], ^bb1, ^bb255! CHECK: ^bb1:56! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_0_DECL]]#0 : !fir.ref<i32>57! CHECK: %[[VAL_6:.*]] = arith.constant false58! CHECK: %[[VAL_7:.*]] = arith.constant false59! CHECK: fir.call @_FortranAStopStatement(%[[VAL_5]], %[[VAL_6]], %[[VAL_7]]) {{.*}} : (i32, i1, i1) -> ()60! CHECK: omp.terminator61! CHECK: ^bb2:62! CHECK: omp.terminator63! CHECK: }64! CHECK: return65! CHECK: }66 67subroutine test_stop_in_region3()68 integer :: x69 !$omp parallel70 x = 371 if (x > 1) stop x72 !$omp end parallel73end74 75! CHECK-LABEL: func.func @_QPtest_stop_in_region4() {76 77! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFtest_stop_in_region4Ei"}78! CHECK: %[[VAL_1_DECL:.*]]:2 = hlfir.declare %[[VAL_1]] {uniq_name = "_QFtest_stop_in_region4Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)79 80! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFtest_stop_in_region4Ex"}81! CHECK: %[[VAL_2_DECL:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFtest_stop_in_region4Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)82 83 84! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i3285! CHECK: %[[VAL_4:.*]] = arith.constant 10 : i3286! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i3287! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_0:.*]] : !fir.ref<i32>) {88! CHECK-NEXT: omp.loop_nest (%[[VAL_6:.*]]) : i32 = (%[[VAL_3]]) to (%[[VAL_4]]) inclusive step (%[[VAL_5]]) {89! CHECK: %[[VAL_0_DECL:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest_stop_in_region4Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)90! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_0_DECL]]#0 : i32, !fir.ref<i32>91! CHECK: cf.br ^bb192! CHECK: ^bb1:93! CHECK: %[[VAL_7:.*]] = arith.constant 3 : i3294! CHECK: hlfir.assign %[[VAL_7]] to %[[VAL_2_DECL]]#0 : i32, !fir.ref<i32>95! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2_DECL]]#0 : !fir.ref<i32>96! CHECK: %[[VAL_9:.*]] = arith.constant 1 : i3297! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_9]] : i3298! CHECK: cf.cond_br %[[VAL_10]], ^bb2, ^bb399! CHECK: ^bb2:100! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_2_DECL]]#0 : !fir.ref<i32>101! CHECK: %[[VAL_12:.*]] = arith.constant false102! CHECK: %[[VAL_13:.*]] = arith.constant false103! CHECK: fir.call @_FortranAStopStatement(%[[VAL_11]], %[[VAL_12]], %[[VAL_13]]) {{.*}} : (i32, i1, i1) -> ()104! CHECK: omp.yield105! CHECK: ^bb3:106! CHECK: omp.yield107! CHECK: }108! CHECK: }109! CHECK: cf.br ^bb1110! CHECK: ^bb1:111! CHECK: return112! CHECK: }113 114subroutine test_stop_in_region4()115 integer :: x116 !$omp do117 do i = 1, 10118 x = 3119 if (x > 1) stop x120 enddo121 !$omp end do122end123 124 125!CHECK-LABEL: func.func @_QPtest_stop_in_region5126!CHECK: omp.parallel {127!CHECK: {{.*}} fir.call @_FortranAStopStatement({{.*}}, {{.*}}, {{.*}}) fastmath<contract> : (i32, i1, i1) -> ()128!CHECK: omp.terminator129!CHECK: }130!CHECK: return131 132subroutine test_stop_in_region5()133 !$omp parallel134 block135 stop 1136 end block137 !$omp end parallel138end139 140!CHECK-LABEL: func.func @_QPtest_stop_in_region6141!CHECK: omp.parallel {142!CHECK: cf.cond_br %{{.*}}, ^[[BB1:.*]], ^[[BB2:.*]]143!CHECK: ^[[BB1]]:144!CHECK: {{.*}}fir.call @_FortranAStopStatement({{.*}}, {{.*}}, {{.*}}) fastmath<contract> : (i32, i1, i1) -> ()145!CHECK: omp.terminator146!CHECK: ^[[BB2]]:147!CHECK: {{.*}}fir.call @_FortranAStopStatement({{.*}}, {{.*}}, {{.*}}) fastmath<contract> : (i32, i1, i1) -> ()148!CHECK: omp.terminator149!CHECK: }150!CHECK: return151 152subroutine test_stop_in_region6(x)153 integer :: x154 !$omp parallel155 if (x .gt. 1) then156 stop 1157 else158 stop 2159 end if160 !$omp end parallel161end162