brintos

brintos / llvm-project-archived public Read only

0
0
Text · 695 B · b88dcaf Raw
18 lines · plain
1// Test the reduction semantics of fir.do_loop2// RUN: fir-opt %s | FileCheck %s3 4func.func @reduction() {5  %bound = arith.constant 10 : index6  %step = arith.constant 1 : index7  %sum = fir.alloca i328// CHECK: %[[VAL_0:.*]] = fir.alloca i329// 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) -> i3212    %1 = fir.load %sum : !fir.ref<i32>13    %2 = arith.addi %index, %1 : i3214    fir.store %2 to %sum : !fir.ref<i32>15  }16  return17}18