[Mlir-commits] [mlir] Add a more complete example to mlir-reduce docs (PR #116085)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat May 2 13:18:45 PDT 2026


aidint wrote:

> if you see a simple tweak of my PR that will cause it to work (maybe replacing the interesting op with one that doesn't fold away and isn't dead?) then I can update this PR.

I tried the following input and also `arith.select` as the interesting op:
```mlir
func.func @func2(%arg0: i1) -> f32 {
  %0 = arith.constant 1 : i32
  %1 = arith.constant 2 : i32
  %2 = arith.constant 2.2 : f32
  %3 = arith.constant 5.3 : f32
  %4 = arith.addi %0, %1 : i32
  %5 = arith.addf %2, %3 : f32
  %6 = arith.muli %4, %4 : i32
  %7 = arith.subi %6, %4 : i32
  %8 = arith.select %arg0, %5, %2 : f32
  %9 = arith.addf %2, %8 : f32
  return %9 : f32
}
```

and it reduce to the following without a segfault:
```mlir
module {
  func.func @func2(%arg0: i1) -> f32 {
    %cst = arith.constant 2.200000e+00 : f32
    %cst_0 = arith.constant 7.500000e+00 : f32
    %0 = arith.select %arg0, %cst_0, %cst : f32
    %1 = arith.addf %0, %cst : f32
    return %1 : f32
  }
```

https://github.com/llvm/llvm-project/pull/116085


More information about the Mlir-commits mailing list