brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 098b3f8 Raw
61 lines · plain
1! This test checks lowering of OpenMP declare reduction Directive, with combiner2! via a subroutine call.3 4!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s5 6subroutine combine_me(out, in)7  integer out, in8  out = out + in9end subroutine combine_me10 11function func(x, n)12  integer func13  integer x(n)14  integer res15  interface16     subroutine combine_me(out, in)17       integer out, in18     end subroutine combine_me19  end interface20!CHECK:  omp.declare_reduction @red_add : i32 init {21!CHECK: ^bb0(%[[OMP_ORIG_ARG_I:.*]]: i32):22!CHECK:    %[[OMP_PRIV:.*]] = fir.alloca i3223!CHECK:    %[[OMP_ORIG:.*]] = fir.alloca i3224!CHECK:    fir.store %[[OMP_ORIG_ARG_I]] to %[[OMP_ORIG]] : !fir.ref<i32>25!CHECK:    %[[OMP_ORIG_DECL:.*]]:2 = hlfir.declare %[[OMP_ORIG]] {uniq_name = "omp_orig"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)26!CHECK:    fir.store %[[OMP_ORIG_ARG_I]] to %[[OMP_PRIV]] : !fir.ref<i32>27!CHECK:    %[[OMP_PRIV_DECL:.*]]:2 = hlfir.declare %[[OMP_PRIV]] {uniq_name = "omp_priv"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)28!CHECK:    %[[CONST_0:.*]] = arith.constant 0 : i3229!CHECK:    omp.yield(%[[CONST_0]] : i32)30!CHECK:  } combiner {31!CHECK:  ^bb0(%[[LHS_ARG:.*]]: i32, %[[RHS_ARG:.*]]: i32):32!CHECK:    %[[OMP_OUT:.*]] = fir.alloca i3233!CHECK:    %[[OMP_IN:.*]] = fir.alloca i3234!CHECK:    fir.store %[[RHS_ARG]] to %[[OMP_IN]] : !fir.ref<i32>35!CHECK:    %[[OMP_IN_DECL:.*]]:2 = hlfir.declare %[[OMP_IN]] {uniq_name = "omp_in"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)36!CHECK:    fir.store %[[LHS_ARG]] to %[[OMP_OUT]] : !fir.ref<i32>37!CHECK:    %[[OMP_OUT_DECL:.*]]:2 = hlfir.declare %[[OMP_OUT]] {uniq_name = "omp_out"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)38!CHECK:    fir.call @_QPcombine_me(%[[OMP_OUT_DECL]]#0, %[[OMP_IN_DECL]]#0) fastmath<contract> : (!fir.ref<i32>, !fir.ref<i32>) -> ()39!CHECK:    %[[OMP_OUT_VAL:.*]] = fir.load %[[OMP_OUT_DECL]]#0 : !fir.ref<i32>40!CHECK:    omp.yield(%[[OMP_OUT_VAL]] : i32)41!CHECK:  }42!CHECK:  func.func @_QPcombine_me(%[[OUT:.*]]: !fir.ref<i32> {fir.bindc_name = "out"}, %[[IN:.*]]: !fir.ref<i32> {fir.bindc_name = "in"}) {43!CHECK:    %[[SCOPE:.*]] = fir.dummy_scope : !fir.dscope44!CHECK:    %[[IN_DECL:.*]]:2 = hlfir.declare %[[IN]] dummy_scope %[[SCOPE]] arg 2 {uniq_name = "_QFcombine_meEin"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)45!CHECK:    %[[OUT_DECL:.*]]:2 = hlfir.declare %[[OUT]] dummy_scope %[[SCOPE]] arg 1 {uniq_name = "_QFcombine_meEout"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)46!CHECK:    %[[OUT_VAL:.*]] = fir.load %[[OUT_DECL]]#0 : !fir.ref<i32>47!CHECK:    %[[IN_VAL:.*]] = fir.load %[[IN_DECL]]#0 : !fir.ref<i32>48!CHECK:    %[[SUM:.*]] = arith.addi %[[OUT_VAL]], %[[IN_VAL]] : i3249!CHECK:    hlfir.assign %[[SUM]] to %[[OUT_DECL]]#0 : i32, !fir.ref<i32>50!CHECK:    return51!CHECK:  }52!$omp declare reduction(red_add:integer(4):combine_me(omp_out,omp_in)) initializer(omp_priv=0)53  res=054!$omp simd reduction(red_add:res)55  do i=1,n56     res=res+x(i)57  enddo58  func=res59end function func60 61