1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
// RUN: mlir-opt -pass-pipeline="builtin.module(any(test-cfg-loop-info))" --split-input-file %s 2>&1 | FileCheck %s
// CHECK-LABEL: Testing : "no_loop_single_block"
// CHECK: no loops
func.func @no_loop_single_block() {
return
}
// -----
// CHECK-LABEL: Testing : "no_loop"
// CHECK: no loops
func.func @no_loop() {
cf.br ^bb1
^bb1:
return
}
// -----
// CHECK-LABEL: Testing : "simple_loop"
// CHECK-NEXT: Blocks : ^[[BB0:.*]], ^[[BB1:.*]], ^[[BB2:.*]], ^[[BB3:.*]]
// CHECK: Loop at depth 1 containing:
// CHECK-SAME: ^[[BB1]]<header><exiting>
// CHECK-SAME: ^[[BB2]]<latch>
func.func @simple_loop(%c: i1) {
cf.br ^bb1
^bb1:
cf.cond_br %c, ^bb2, ^bb3
^bb2:
cf.br ^bb1
^bb3:
return
}
// -----
// CHECK-LABEL: Testing : "single_block_loop"
// CHECK-NEXT: Blocks : ^[[BB0:.*]], ^[[BB1:.*]], ^[[BB2:.*]]
// CHECK: Loop at depth 1 containing:
// CHECK-SAME: ^[[BB1]]<header><latch><exiting>
func.func @single_block_loop(%c: i1) {
cf.br ^bb1
^bb1:
cf.cond_br %c, ^bb1, ^bb2
^bb2:
return
}
// -----
// CHECK-LABEL: Testing : "nested_loop"
// CHECK-NEXT: Blocks : ^[[BB0:.*]], ^[[BB1:.*]], ^[[BB2:.*]], ^[[BB3:.*]], ^[[BB4:.*]]
// CHECK: Loop at depth 1
// CHECK-SAME: ^[[BB1]]<header><exiting>
// CHECK-SAME: ^[[BB2]]<latch>
// CHECK-SAME: ^[[BB3]]
// CHECK: Loop at depth 2
// CHECK-SAME: ^[[BB2]]<header><exiting>
// CHECK-SAME: ^[[BB3]]<latch>
func.func @nested_loop(%c: i1) {
cf.br ^bb1
^bb1:
cf.cond_br %c, ^bb2, ^bb4
^bb2:
cf.cond_br %c, ^bb1, ^bb3
^bb3:
cf.br ^bb2
^bb4:
return
}
// -----
// CHECK-LABEL: Testing : "multi_latch"
// CHECK-NEXT: Blocks : ^[[BB0:.*]], ^[[BB1:.*]], ^[[BB2:.*]], ^[[BB3:.*]], ^[[BB4:.*]]
// CHECK: Loop at depth 1
// CHECK-SAME: ^[[BB1]]<header><exiting>
// CHECK-SAME: ^[[BB2]]<latch>
// CHECK-SAME: ^[[BB3]]<latch>
func.func @multi_latch(%c: i1) {
cf.br ^bb1
^bb1:
cf.cond_br %c, ^bb4, ^bb2
^bb2:
cf.cond_br %c, ^bb1, ^bb3
^bb3:
cf.br ^bb1
^bb4:
return
}
// -----
// CHECK-LABEL: Testing : "multiple_loops"
// CHECK-NEXT: Blocks : ^[[BB0:.*]], ^[[BB1:.*]], ^[[BB2:.*]], ^[[BB3:.*]], ^[[BB4:.*]], ^[[BB5:.*]]
// CHECK: Loop at depth 1
// CHECK-SAME: ^[[BB3]]<header><exiting>
// CHECK-SAME: ^[[BB4]]<latch>
// CHECK: Loop at depth 1
// CHECK-SAME: ^[[BB1]]<header>
// CHECK-SAME: ^[[BB2]]<latch><exiting>
func.func @multiple_loops(%c: i1) {
cf.br ^bb1
^bb1:
cf.br ^bb2
^bb2:
cf.cond_br %c, ^bb3, ^bb1
^bb3:
cf.cond_br %c, ^bb5, ^bb4
^bb4:
cf.br ^bb3
^bb5:
return
}
|