[Instcombine] Need to check one-use for the combinations in foldAndOrOfICmps
https://godbolt.org/z/Gh39n1YK3
define i1 @src(i8 %x, i8 %y) {
%cmp1 = icmp ne i8 %x, 0
%cmp2 = icmp ne i8 %y, 0
%or = or i1 %cmp1, %cmp2
%r = call i1 @use(i1 %or, i1 %cmp1, i1 %cmp2)
ret i1 %r
}
declare i1 @use(i1, i1, i1)
It might be better to view this as a missed simplification: https://alive2.llvm.org/ce/z/zvT7eh
It might be better to view this as a missed simplification: https://alive2.llvm.org/ce/z/zvT7eh
Yeah, this test case is not good enough to show the title. Maybe this one can be better:
define i1 @src(i8 %x, i8 %y) {
%cmp1 = icmp ne i8 %x, 0
%cmp2 = icmp ne i8 %y, 0
%or = or i1 %cmp1, %cmp2
%r = call i1 @use(i1 %or, i1 %cmp1, i1 %cmp2)
ret i1 %r
}
declare i1 @use(i1, i1, i1)
https://godbolt.org/z/Gh39n1YK3
For the simplification you mentioned, this should be more general: https://alive2.llvm.org/ce/z/Li-Eqq
candidate patch: https://reviews.llvm.org/D138744
candidate patch: https://reviews.llvm.org/D138744
I have already send a patch on D138700 for the pattern spatel mentioned. And this ticket is used for tracking lack one-use.
Let's proceed with D138700.