summaryrefslogtreecommitdiff
path: root/flang/test/Transforms/external-name-interop-symref-array.fir
blob: ce14f17fbf30af39cf532165b0b8dfaa5ad5fbff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Test fir.do_concurrent.loop operation with array of symbol reference attributes
// This test demonstrates operations that have ArrayAttr containing SymbolRefAttr elements

// RUN: fir-opt %s --external-name-interop | fir-opt | FileCheck %s

// Define reduction operations that will be referenced in the symbol array
func.func @_QPadd_reduction_i32_init(%arg0: i32, %arg1: !fir.ref<i32>) {
  %0 = arith.constant 0 : i32
  fir.store %0 to %arg1 : !fir.ref<i32>
  return
}

func.func @_QPadd_reduction_i32_combiner(%arg0: i32, %arg1: i32) -> i32 {
  %0 = arith.addi %arg0, %arg1 : i32
  return %0 : i32
}

// Define a local privatizer that will be referenced in local_syms
func.func @_QPlocal_var_privatizer(%arg0: !fir.ref<i32>) -> !fir.ref<i32> {
  return %arg0 : !fir.ref<i32>
}

// Test function demonstrating both local_syms and reduce_syms arrays
func.func @_QPtest_symbol_arrays(%i_lb: index, %i_ub: index, %i_st: index) {
  %local_var = fir.alloca i32
  %sum = fir.alloca i32
  
  fir.do_concurrent {
    %i = fir.alloca i32
    fir.do_concurrent.loop (%i_iv) = (%i_lb) to (%i_ub) step (%i_st)
      local(@_QPlocal_var_privatizer %local_var -> %local_arg : !fir.ref<i32>)
      reduce(@_QPadd_reduction_i32_init #fir.reduce_attr<add> %sum -> %sum_arg : !fir.ref<i32>) {
      %0 = fir.convert %i_iv : (index) -> i32
      fir.store %0 to %i : !fir.ref<i32>
    }
  }
  return
}

// CHECK: local(@local_var_privatizer_
// CHECK: reduce(@add_reduction_i32_init_