!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s !XFAIL: * module mod contains subroutine foo(dt, switch) implicit none real(4), dimension(:), intent(inout) :: dt logical, intent(in) :: switch integer :: dim, idx if (switch) then !$omp target teams distribute parallel do do idx = 1, 100 dt(idx) = 20 end do else !$omp target teams distribute parallel do do idx = 1, 100 dt(idx) = 30 end do end if end subroutine foo end module ! CHECK-LABEL: func.func @{{.*}}( ! CHECK-SAME: %[[ARG0:.*]]: !fir.box> {fir.bindc_name = "dt"}, ! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box> ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope {{.*}} ! CHECK: fir.if %{{.*}} { ! CHECK: %[[VAL_2:.*]] = fir.is_present %[[VAL_1]]#1 : (!fir.box>) -> i1 ! CHECK: fir.if %[[VAL_2]] { ! CHECK: fir.store %[[VAL_1]]#1 to %[[VAL_0]] : !fir.ref>> ! CHECK: } ! CHECK: %[[VAL_3:.*]] = fir.box_offset %[[VAL_0]] base_addr : (!fir.ref>>) -> !fir.llvm_ptr>> ! CHECK: %[[VAL_4:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref>>, !fir.box>) map_clauses(implicit, tofrom) capture(ByRef) var_ptr_ptr(%[[VAL_3]] : !fir.llvm_ptr>>, f32) bounds(%{{.*}}) -> !fir.llvm_ptr>> {name = ""} ! CHECK: %[[VAL_5:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref>>, !fir.box>) map_clauses(always, implicit, to) capture(ByRef) members(%[[VAL_4]] : [0] : !fir.llvm_ptr>>) -> !fir.ref> {name = "dt"} ! CHECK: omp.target host_eval({{.*}}) map_entries({{.*}}%[[VAL_5]] -> {{.*}}, %[[VAL_4]] -> {{.*}} : {{.*}}) { ! CHECK: } else { ! CHECK: %[[VAL_6:.*]] = fir.is_present %[[VAL_1]]#1 : (!fir.box>) -> i1 ! CHECK: fir.if %[[VAL_6]] { ! CHECK: fir.store %[[VAL_1]]#1 to %[[VAL_0]] : !fir.ref>> ! CHECK: } ! CHECK: %[[VAL_7:.*]] = fir.box_offset %[[VAL_0]] base_addr : (!fir.ref>>) -> !fir.llvm_ptr>> ! CHECK: %[[VAL_8:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref>>, !fir.box>) map_clauses(implicit, tofrom) capture(ByRef) var_ptr_ptr(%[[VAL_7]] : !fir.llvm_ptr>>, f32) bounds(%{{.*}}) -> !fir.llvm_ptr>> {name = ""} ! CHECK: %[[VAL_9:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref>>, !fir.box>) map_clauses(always, implicit, to) capture(ByRef) members(%[[VAL_8]] : [0] : !fir.llvm_ptr>>) -> !fir.ref> {name = "dt"} ! CHECK: omp.target host_eval({{.*}}) map_entries({{.*}}, %[[VAL_9]] ->{{.*}}, %[[VAL_8]] -> {{.*}} : {{.*}}) {