Input:
func.func @foo(%arg: index) {
scf.index_switch %arg
case 4294967296 { // 2^32
"op.op"() : () -> ()
scf.yield
}
case 8589934592 { // 2^33
"op.op"() : () -> ()
scf.yield
}
default {
"op.op"() : () -> ()
scf.yield
}
return
}
Using latest mlir-opt
// mlir-opt --convert-scf-to-cf --allow-unregistered-dialect
module {
func.func @foo(%arg0: index) {
%0 = arith.index_cast %arg0 : index to i32
cf.switch %0 : i32, [
default: ^bb3,
0: ^bb1,
0: ^bb2
]
^bb1: // pred: ^bb0
"op.op"() : () -> ()
cf.br ^bb4
^bb2: // pred: ^bb0
"op.op"() : () -> ()
cf.br ^bb4
^bb3: // pred: ^bb0
"op.op"() : () -> ()
cf.br ^bb4
^bb4: // 3 preds: ^bb1, ^bb2, ^bb3
return
}
}
This is caused by an overflow here:
|
SmallVector<int32_t> caseValues; |
, where the case values are actually
int64_t.
Link to Goldbolt: https://godbolt.org/z/bvbW51WM4