1 // RUN: mlir-opt -convert-scf-to-spirv %s -o - | FileCheck %s
3 // CHECK-LABEL: @forward
5 // CHECK: %[[LB:.*]] = spirv.Constant 0 : i32
6 %c0 = arith.constant 0 : index
7 // CHECK: %[[UB:.*]] = spirv.Constant 32 : i32
8 %c32 = arith.constant 32 : index
9 // CHECK: %[[STEP:.*]] = spirv.Constant 1 : i32
10 %c1 = arith.constant 1 : index
12 // CHECK: spirv.mlir.loop {
13 // CHECK-NEXT: spirv.Branch ^[[HEADER:.*]](%[[LB]] : i32)
14 // CHECK: ^[[HEADER]](%[[INDVAR:.*]]: i32):
15 // CHECK: %[[CMP:.*]] = spirv.SLessThan %[[INDVAR]], %[[UB]] : i32
16 // CHECK: spirv.BranchConditional %[[CMP]], ^[[BODY:.*]], ^[[MERGE:.*]]
18 // CHECK: %[[X:.*]] = spirv.IAdd %[[INDVAR]], %[[INDVAR]] : i32
19 // CHECK: %[[INDNEXT:.*]] = spirv.IAdd %[[INDVAR]], %[[STEP]] : i32
20 // CHECK: spirv.Branch ^[[HEADER]](%[[INDNEXT]] : i32)
22 // CHECK: spirv.mlir.merge
24 scf.for %arg2 = %c0 to %c32 step %c1 {
25 %1 = index.add %arg2, %arg2