brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · a41f6b2 Raw
34 lines · plain
1! This test checks lowering of OpenMP declare reduction Directive.2 3!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s4 5subroutine declare_red()6  integer :: my_var7!CHECK: omp.declare_reduction @my_red : i32 init {8!CHECK: ^bb0(%[[OMP_ORIG_ARG_I:.*]]: i32):9!CHECK:    %[[OMP_PRIV:.*]] = fir.alloca i3210!CHECK:    %[[OMP_ORIG:.*]] = fir.alloca i3211!CHECK:    fir.store %[[OMP_ORIG_ARG_I]] to %[[OMP_ORIG]] : !fir.ref<i32>12!CHECK:    %[[OMP_ORIG_DECL:.*]]:2 = hlfir.declare %[[OMP_ORIG]] {uniq_name = "omp_orig"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)13!CHECK:    fir.store %[[OMP_ORIG_ARG_I]] to %[[OMP_PRIV]] : !fir.ref<i32>14!CHECK:    %[[OMP_PRIV_DECL:.*]]:2 = hlfir.declare %[[OMP_PRIV]] {uniq_name = "omp_priv"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)15!CHECK:    %[[CONST_0:.*]] = arith.constant 0 : i3216!CHECK:    omp.yield(%[[CONST_0]] : i32)17!CHECK: } combiner {18!CHECK:  ^bb0(%[[LHS_ARG:.*]]: i32, %[[RHS_ARG:.*]]: i32):19!CHECK:    %[[OMP_OUT:.*]] = fir.alloca i3220!CHECK:    %[[OMP_IN:.*]] = fir.alloca i3221!CHECK:    fir.store %[[RHS_ARG]] to %[[OMP_IN]] : !fir.ref<i32>22!CHECK:    %[[OMP_IN_DECL:.*]]:2 = hlfir.declare %[[OMP_IN]] {uniq_name = "omp_in"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)23!CHECK:    fir.store %[[LHS_ARG]] to %[[OMP_OUT]] : !fir.ref<i32>24!CHECK:    %[[OMP_OUT_DECL:.*]]:2 = hlfir.declare %[[OMP_OUT]] {uniq_name = "omp_out"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)25!CHECK:    %[[OMP_OUT_VAL:.*]] = fir.load %[[OMP_OUT_DECL]]#0 : !fir.ref<i32>26!CHECK:    %[[OMP_IN_VAL:.*]] = fir.load %[[OMP_IN_DECL]]#0 : !fir.ref<i32>27!CHECK:    %[[SUM:.*]] = arith.addi %[[OMP_OUT_VAL]], %[[OMP_IN_VAL]] : i3228!CHECK:    omp.yield(%[[SUM]] : i32)29!CHECK: }30 31  !$omp declare reduction (my_red : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)32  my_var = 033end subroutine declare_red34