1 // Test the reduction semantics of fir.do_loop
2 // RUN: fir-opt %s | FileCheck %s
4 func.func @reduction() {
5 %bound = arith.constant 10 : index
6 %step = arith.constant 1 : index
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>) {
10 fir.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
14 fir.store %2 to %sum : !fir.ref<i32>