<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87430>87430</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] Unable to roundtrip `cf.switch`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Kuree
</td>
</tr>
</table>
<pre>
The IR below is an invalid IR since `%0` has two results but can be used directly with `^bb1(%0: i32)`. For some reason `mlir-opt` has no issue with it and even outputs correct IR. The output, however, can't be parsed due to the following error:
```
error: result number not allowed in argument list
0: ^bb1(%0#0 : i32)
^
```
```mlir
module {
func.func @foo(%arg0: i32, %arg1: i1) -> i32 {
%c0_i32 = arith.constant 0 : i32
%0:2 = scf.if %arg1 -> (i32, i32) {
scf.yield %c0_i32, %c0_i32 : i32, i32
} else {
scf.yield %c0_i32, %c0_i32 : i32, i32
}
cf.switch %arg0 : i32, [
default: ^bb2,
0: ^bb1(%0 : i32)
]
^bb1(%1: i32): // pred: ^bb0
return %1 : i32
^bb2: // pred: ^bb0
return %c0_i32 : i32
}
}
```
See godbolt with MLIR trunk: https://godbolt.org/z/szcz8bKEY.
What is the reason behind setting this parameter to false?
https://github.com/llvm/llvm-project/blob/e61d6b74ddf28df196484f6251271f543ae902ab/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp#L534-L538
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVV1vrDYQ_TXel1GQsWFhH3i4Nxuk6KaqlLaq-lQZPCxuvTbyR1bJr68M7Ff6IV2pUcTCcHzOmTEzFt6rg0FsSPmVlPuNiGG0rvkWHeKms_K9-XlEeH6FDrU9gfIgDCjzJrSSKeyV6RHIlhJWUrKlMAoP4WTBoY86eOhigF4Y6BCiRwlSOeyDfoeTCuO8sHzqupywembgX0BxRtiObGkGrXXg7RHBofDWJPhRK_dgp3DWMhaU9xEXPh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