74 lines · plain
1! Tests that "loop-local values" are properly handled by localizing them to the2! body of the loop nest. See `collectLoopLocalValues` and `localizeLoopLocalValue`3! for a definition of "loop-local values" and how they are handled.4 5! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host %s -o - \6! RUN: | FileCheck %s --check-prefixes=COMMON7 8! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=device %s -o - \9! RUN: | FileCheck %s --check-prefixes=COMMON,DEVICE10module struct_mod11 type test_struct12 integer, allocatable :: x_13 end type14 15 interface test_struct16 pure module function construct_from_components(x) result(struct)17 implicit none18 integer, intent(in) :: x19 type(test_struct) struct20 end function21 end interface22end module23 24submodule(struct_mod) struct_sub25 implicit none26 27contains28 module procedure construct_from_components29 struct%x_ = x30 end procedure31end submodule struct_sub32 33program main34 use struct_mod, only : test_struct35 36 implicit none37 type(test_struct), dimension(10) :: a38 integer :: i39 integer :: total40 41 do concurrent (i=1:10)42 a(i) = test_struct(i)43 end do44 45 do i=1,1046 total = total + a(i)%x_47 end do48 49 print *, "total =", total50end program main51 52! DEVICE: omp.target {{.*}} {53! DEVICE: omp.teams {54! COMMON: omp.parallel {55! COMMON: %[[LOCAL_TEMP:.*]] = fir.alloca !fir.type<_QMstruct_modTtest_struct{x_:!fir.box<!fir.heap<i32>>}> {bindc_name = ".result"}56! DEVICE: omp.distribute {57! COMMON: omp.wsloop {58! COMMON: omp.loop_nest {{.*}} {59! COMMON: %[[TEMP_VAL:.*]] = fir.call @_QMstruct_modPconstruct_from_components60! COMMON: fir.save_result %[[TEMP_VAL]] to %[[LOCAL_TEMP]]61! COMMON: %[[EMBOXED_LOCAL:.*]] = fir.embox %[[LOCAL_TEMP]]62! COMMON: %[[CONVERTED_LOCAL:.*]] = fir.convert %[[EMBOXED_LOCAL]]63! COMMON: fir.call @_FortranADestroy(%[[CONVERTED_LOCAL]])64! COMMON: omp.yield65! COMMON: }66! COMMON: }67! DEVICE: }68! COMMON: omp.terminator69! COMMON: }70! DEVICE: omp.terminator71! DEVICE: }72! DEVICE: omp.terminator73! DEVICE: }74