Closed
Description
For example,
define i64 @demo(i64 %x) {
entry:
switch i64 %x, label %bb3 [
i64 0, label %bb1
i64 1, label %bb2
]
bb1:
ret i64 0
bb2:
%0 = icmp eq i64 %x, 100 ; this will necessarily be false because %x == 1
br i1 %0, label %bb4, label %bb5
bb3:
unreachable
bb4:
ret i64 200
bb5:
ret i64 10
}
See: https://godbolt.org/z/3nobrzoKa
This is a known issue from rust: rust-lang/rust#85133 (comment)
We want to get the IR result after SimplifyCFG:
define i64 @src(i64 %x) {
%entry:
%switch = icmp eq i64 %x, 0
%. = select i1 %switch, i64 0, i64 10
ret i64 %.
}