[Mlir-commits] [mlir] [mlir] Fix block merging (PR #97697)

Christian Ulmann llvmlistbot at llvm.org
Wed Jul 24 08:18:50 PDT 2024


Dinistro wrote:

This seems to be incorrect, after this patch, the following IR example explodes when running canonicalizations with aggressive region simplifications:

```
  llvm.func @reproducer() {
    %0 = llvm.mlir.zero : !llvm.ptr
    %1 = llvm.mlir.constant(false) : i1
    %2 = llvm.mlir.constant(true) : i1
    llvm.cond_br %1, ^bb7(%0 : !llvm.ptr), ^bb1(%0 : !llvm.ptr)
  ^bb1(%3: !llvm.ptr):  // pred: ^bb0
    llvm.store %3, %0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr
    llvm.cond_br %1, ^bb2(%2 : i1), ^bb4(%2 : i1)
  ^bb2(%4: i1):  // 2 preds: ^bb1, ^bb7
    llvm.cond_br %1, ^bb3(%4 : i1), ^bb4(%4 : i1)
  ^bb3(%5: i1):  // pred: ^bb2
    llvm.br ^bb4(%5 : i1)
  ^bb4(%6: i1):  // 4 preds: ^bb1, ^bb2, ^bb3, ^bb7
    llvm.cond_br %6, ^bb6, ^bb5
  ^bb5:  // pred: ^bb4
    llvm.br ^bb6
  ^bb6:  // 2 preds: ^bb4, ^bb5
    llvm.br ^bb8
  ^bb7(%7: !llvm.ptr):  // pred: ^bb0
    llvm.store %7, %0 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr
    llvm.cond_br %1, ^bb2(%1 : i1), ^bb4(%1 : i1)
  ^bb8:  // pred: ^bb6
    llvm.return
  }
```

It seems that there is a type mismatch between branch operands and block arguments.

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


More information about the Mlir-commits mailing list