~builtin.module() ({ ~func.func() ({ ^entry(%buffer: i32, %lb: index, %ub: index, %step: index): ; Initial sum set to 0. %sum.0 = ~arith.constant() {value = 0.0 : f32} : () -> f32 ; iter_args binds initial values to the loop's region arguments. ;%sum = "scf.for"(%lb, %ub, %step) -> (f32) { ~cf.br() [ ^for.entry:(%lb: index, %sum.0: f32) ] : () -> () ^for.entry(%iv: index, %sum.iter: f32): %t, %x, %z = ~memref.load(%buffer, %iv) : (i32, index) -> (f32, i1, i1) %sum.next = ~arith.addf(%sum.iter, %t) : (f32, f32) -> f32 ~cf.br() [ ^for.cond:(%iv: index, %sum.next: f32) ] : () -> () ^for.cond(%iv2: index, %sum.next2: f32): ; Yield current iteration sum to next iteration %sum.iter or to %sum ; if final iteration. %iv.next = ~arith.addi(%iv, %step) : (index, index) -> index %stop = ~arith.cmpi(%iv.next, %ub) { predicate = 9 } : (index, index) -> i1 ~cf.br-cond(%stop) [ ^for.end, ^for.entry:(%iv.next: index, %sum.next: f32) ] : (i1) -> () ^for.end(%sum: f32): ~func.return(%sum) : (f32) -> () }) {sym_name = "reduce", function_type = (i32, index, index, index) -> f32 } : () -> () }) : () -> ()