[Caylx] canonicalization results in invalid IR: ifOp w/empty else
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Verifier checks that else region is non-empty if present.
Current patterns can fail this verification, for example when the else region contains some control op that removes itself (`emptyControl`) the containing block is now newly empty and fails verification.
Caught by ` -DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.`.
cc #7047.
This can be observed with the following example from `test/Dialect/Calyx/canonicalization.mlir`:
```mlir
module attributes {calyx.entrypoint = "main"} {
calyx.component @main(%go: i1 {go}, %clk: i1 {clk}, %reset: i1 {reset}) -> (%done: i1 {done}) {
%r.in, %r.write_en, %r.clk, %r.reset, %r.out, %r.done = calyx.register @r : i1, i1, i1, i1, i1, i1
%eq.left, %eq.right, %eq.out = calyx.std_eq @eq : i1, i1, i1
%c1_1 = hw.constant 1 : i1
calyx.wires {
calyx.comb_group @Cond {
calyx.assign %eq.left = %c1_1 : i1
calyx.assign %eq.right = %c1_1 : i1
}
calyx.group @A {
calyx.assign %r.in = %c1_1 : i1
calyx.assign %r.write_en = %c1_1 : i1
calyx.group_done %r.done : i1
}
}
calyx.control {
calyx.seq {
calyx.if %eq.out with @Cond {
calyx.seq {
calyx.enable @A
}
} else {
calyx.seq {
calyx.enable @A
}
}
}
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure from test/Dialect/Calyx/canonicalization.mlir with MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON. Trace the Calyx canonicalization patterns involving emptyControl and the if operation's else region. Done means the example no longer produces an invalid empty else region and the canonicalization test passes verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100