| 1 |
// RUN: fir-opt --split-input-file --cfg-conversion %s | FileCheck %s |
| 2 |
|
| 3 |
func.func private @callee() -> none |
| 4 |
|
| 5 |
// CHECK-LABEL: func.func @if_then( |
| 6 |
// CHECK-SAME: %[[ARG0:.*]]: i1) { |
| 7 |
// CHECK: cf.cond_br %[[ARG0]] weights([10, 90]), ^bb1, ^bb2 |
| 8 |
// CHECK: ^bb1: |
| 9 |
// CHECK: %[[VAL_0:.*]] = fir.call @callee() : () -> none |
| 10 |
// CHECK: cf.br ^bb2 |
| 11 |
// CHECK: ^bb2: |
| 12 |
// CHECK: return |
| 13 |
// CHECK: } |
| 14 |
func.func @if_then(%cond: i1) { |
| 15 |
fir.if %cond weights([10, 90]) { |
| 16 |
fir.call @callee() : () -> none |
| 17 |
} |
| 18 |
return |
| 19 |
} |
| 20 |
|
| 21 |
// ----- |
| 22 |
|
| 23 |
// CHECK-LABEL: func.func @if_then_else( |
| 24 |
// CHECK-SAME: %[[ARG0:.*]]: i1) -> i32 { |
| 25 |
// CHECK: %[[VAL_0:.*]] = arith.constant 0 : i32 |
| 26 |
// CHECK: %[[VAL_1:.*]] = arith.constant 1 : i32 |
| 27 |
// CHECK: cf.cond_br %[[ARG0]] weights([90, 10]), ^bb1, ^bb2 |
| 28 |
// CHECK: ^bb1: |
| 29 |
// CHECK: cf.br ^bb3(%[[VAL_0]] : i32) |
| 30 |
// CHECK: ^bb2: |
| 31 |
// CHECK: cf.br ^bb3(%[[VAL_1]] : i32) |
| 32 |
// CHECK: ^bb3(%[[VAL_2:.*]]: i32): |
| 33 |
// CHECK: cf.br ^bb4 |
| 34 |
// CHECK: ^bb4: |
| 35 |
// CHECK: return %[[VAL_2]] : i32 |
| 36 |
// CHECK: } |
| 37 |
func.func @if_then_else(%cond: i1) -> i32 { |
| 38 |
%c0 = arith.constant 0 : i32 |
| 39 |
%c1 = arith.constant 1 : i32 |
| 40 |
%result = fir.if %cond weights([90, 10]) -> i32 { |
| 41 |
fir.result %c0 : i32 |
| 42 |
} else { |
| 43 |
fir.result %c1 : i32 |
| 44 |
} |
| 45 |
return %result : i32 |
| 46 |
} |