1// RUN: mlir-opt -convert-openmp-to-llvm %s  -split-input-file | FileCheck %s
2
3// CHECK-LABEL: llvm.func @branch_loop
4func @branch_loop() {
5  %start = constant 0 : index
6  %end = constant 0 : index
7  // CHECK: omp.parallel
8  omp.parallel {
9    // CHECK-NEXT: llvm.br ^[[BB1:.*]](%{{[0-9]+}}, %{{[0-9]+}} : !llvm.i64, !llvm.i64
10    br ^bb1(%start, %end : index, index)
11  // CHECK-NEXT: ^[[BB1]](%[[ARG1:[0-9]+]]: !llvm.i64, %[[ARG2:[0-9]+]]: !llvm.i64):{{.*}}
12  ^bb1(%0: index, %1: index):
13    // CHECK-NEXT: %[[CMP:[0-9]+]] = llvm.icmp "slt" %[[ARG1]], %[[ARG2]] : !llvm.i64
14    %2 = cmpi "slt", %0, %1 : index
15    // CHECK-NEXT: llvm.cond_br %[[CMP]], ^[[BB2:.*]](%{{[0-9]+}}, %{{[0-9]+}} : !llvm.i64, !llvm.i64), ^[[BB3:.*]]
16    cond_br %2, ^bb2(%end, %end : index, index), ^bb3
17  // CHECK-NEXT: ^[[BB2]](%[[ARG3:[0-9]+]]: !llvm.i64, %[[ARG4:[0-9]+]]: !llvm.i64):
18  ^bb2(%3: index, %4: index):
19    // CHECK-NEXT: llvm.br ^[[BB1]](%[[ARG3]], %[[ARG4]] : !llvm.i64, !llvm.i64)
20    br ^bb1(%3, %4 : index, index)
21  // CHECK-NEXT: ^[[BB3]]:
22  ^bb3:
23    omp.flush
24    omp.barrier
25    omp.taskwait
26    omp.taskyield
27    omp.terminator
28  }
29  return
30}
31
32// CHECK-LABEL: @wsloop
33// CHECK: (%[[ARG0:.*]]: !llvm.i64, %[[ARG1:.*]]: !llvm.i64, %[[ARG2:.*]]: !llvm.i64, %[[ARG3:.*]]: !llvm.i64, %[[ARG4:.*]]: !llvm.i64, %[[ARG5:.*]]: !llvm.i64)
34func @wsloop(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4: index, %arg5: index) {
35  // CHECK: omp.parallel
36  omp.parallel {
37    // CHECK: omp.wsloop
38    // CHECK: (%[[ARG0]], %[[ARG1]], %[[ARG2]], %[[ARG3]], %[[ARG4]], %[[ARG5]])
39    "omp.wsloop"(%arg0, %arg1, %arg2, %arg3, %arg4, %arg5) ( {
40    // CHECK: ^{{.*}}(%[[ARG6:.*]]: !llvm.i64, %[[ARG7:.*]]: !llvm.i64):
41    ^bb0(%arg6: index, %arg7: index):  // no predecessors
42      // CHECK: "test.payload"(%[[ARG6]], %[[ARG7]]) : (!llvm.i64, !llvm.i64) -> ()
43      "test.payload"(%arg6, %arg7) : (index, index) -> ()
44      omp.yield
45    }) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 0, 0, 0]> : vector<9xi32>} : (index, index, index, index, index, index) -> ()
46    omp.terminator
47  }
48  return
49}
50