[all-commits] [llvm/llvm-project] 07d8fe: [mlir][scf] Add an IndexSwitchOp

Jeff Niu via All-commits all-commits at lists.llvm.org
Fri Oct 21 09:21:24 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 07d8fe9391a1bda7bb5fdfd17a5b897df7a003f5
      https://github.com/llvm/llvm-project/commit/07d8fe9391a1bda7bb5fdfd17a5b897df7a003f5
  Author: Jeff Niu <jeff at modular.com>
  Date:   2022-10-21 (Fri, 21 Oct 2022)

  Changed paths:
    M mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
    M mlir/lib/Dialect/SCF/IR/SCF.cpp
    M mlir/test/Dialect/SCF/invalid.mlir
    M mlir/test/Dialect/SCF/ops.mlir

  Log Message:
  -----------
  [mlir][scf] Add an IndexSwitchOp

The `scf.index_switch` is a control-flow operation that branches to one of the
given regions based on the values of the argument and the cases. The
argument is always of type `index`.

Example:

```mlir
%0 = scf.index_switch %arg0 -> i32
case 2 {
  %1 = arith.constant 10 : i32
  scf.yield %1 : i32
}
case 5 {
  %2 = arith.constant 20 : i32
  scf.yield %2 : i32
}
default {
  %3 = arith.constant 30 : i32
  scf.yield %3 : i32
}
```

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D136003




More information about the All-commits mailing list