[all-commits] [llvm/llvm-project] 176ab0: [MLIR][Conversion] Remove func dialect dependency ...

Yue Huang via All-commits all-commits at lists.llvm.org
Fri Sep 11 06:05:22 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 176ab0177fb9acf749b90634cae84936fcfac2c5
      https://github.com/llvm/llvm-project/commit/176ab0177fb9acf749b90634cae84936fcfac2c5
  Author: Yue Huang <2292398666 at qq.com>
  Date:   2026-09-11 (Fri, 11 Sep 2026)

  Changed paths:
    M mlir/include/mlir/Conversion/ControlFlowToSCF/ControlFlowToSCF.h
    M mlir/include/mlir/Conversion/Passes.td
    M mlir/include/mlir/Transforms/CFGToSCF.h
    M mlir/lib/Conversion/ControlFlowToSCF/CMakeLists.txt
    M mlir/lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp
    M mlir/lib/Transforms/Utils/CFGToSCF.cpp
    M mlir/test/Conversion/ControlFlowToSCF/test.mlir

  Log Message:
  -----------
  [MLIR][Conversion] Remove func dialect dependency for CF to SCF conversion (#222594)

The pass used to target only `func.func` and generates a `func.return`
with poison values. Now we change it to `ub.unreachable`, as the TODO
suggests.

But this change alone can cause the following pattern to appear after
lifting:
```mlir
func.func @f(%arg0: f32, %arg1: i1) -> f32 {
    cf.cond_br %arg1, ^bb1(%arg0 : f32), ^bb2
^bb1(%0: f32):  // pred: ^bb0
    ub.unreachable
^bb2:  // pred: ^bb0
    return %arg0 : f32
}
```

This `cf.cond_br` cannot be raised further into `scf.if`, because we
need something as the operand of `return`, while `ub.unreachable`
doesn't provide this. Therefore we reused the code of synthesizing
poison values when `ub.unreachable` can be merged to other return
operations.

---------

Co-authored-by: Markus Böck <markus.boeck02 at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list