Open
Description
We currently fail to fold variations of this pattern:
https://alive2.llvm.org/ce/z/tT3yNU
define i1 @src(i64 %a, i1 %c) {
%idx = shl nsw i64 %a, 3
%sel = select i1 %c, i64 8, i64 0
%cmp = icmp eq i64 %idx, %sel
ret i1 %cmp
}
define i1 @tgt(i64 %a, i1 %c) {
%sel = select i1 %c, i64 1, i64 0
%cmp = icmp eq i64 %a, %sel
ret i1 %cmp
}
The underlying pattern here is something like f(x) == y
converted to x == f^-1(y)
where f invertible and f^-1(y)
folds because the shift arms are constant.