llvm-project
17 строк · 695.0 Байт
1// Test the reduction semantics of fir.do_loop
2// RUN: fir-opt %s | FileCheck %s
3
4func.func @reduction() {
5%bound = arith.constant 10 : index
6%step = arith.constant 1 : index
7%sum = fir.alloca i32
8// CHECK: %[[VAL_0:.*]] = fir.alloca i32
9// CHECK: fir.do_loop %[[VAL_1:.*]] = %[[VAL_2:.*]] to %[[VAL_3:.*]] step %[[VAL_4:.*]] unordered reduce(#fir.reduce_attr<add> -> %[[VAL_0]] : !fir.ref<i32>) {
10fir.do_loop %iv = %step to %bound step %step unordered reduce(#fir.reduce_attr<add> -> %sum : !fir.ref<i32>) {
11%index = fir.convert %iv : (index) -> i32
12%1 = fir.load %sum : !fir.ref<i32>
13%2 = arith.addi %index, %1 : i32
14fir.store %2 to %sum : !fir.ref<i32>
15}
16return
17}
18