Open
Description
----------------------------------------
define i16 @src(i1 %cnd) {
entry:
%sel = select i1 %cnd, i16 0, i16 3
%trunc = trunc i16 %sel to i8
switch i8 %trunc, label %bb_unreachable [
i8 0, label %bb_true_path
i8 3, label %bb_false_path
]
bb_false_path:
br label %bb_merge
bb_true_path:
br label %bb_merge
bb_unreachable:
br label %bb_merge
bb_merge:
%final_result = phi i16 [ %sel, %bb_unreachable ], [ 99, %bb_true_path ], [ 100, %bb_false_path ]
ret i16 %final_result
}
=>
define i16 @tgt(i1 %cnd) {
#0:
%switch.select = select i1 %cnd, i16 99, i16 100
ret i16 %switch.select
}
Transformation seems to be correct!
It's worth noting that replacing the constant(s) 3
with 4
in the example enables the expected simplification.
https://godbolt.org/z/eMqa6Gs3Y
https://alive2.llvm.org/ce/z/H34-Co