This patch adds A & (A && B) -> A && B (similarly for or + logical or)
Also, this patch adds ~(select C, (icmp pred X, Y), const) -> select C, (icmp pred' X, Y), ~const.
Alive2 proof:
merge_and: https://alive2.llvm.org/ce/z/teMR97
merge_or: https://alive2.llvm.org/ce/z/b4yZUp
xor_and: https://alive2.llvm.org/ce/z/_-TXHi
xor_or: https://alive2.llvm.org/ce/z/2uYx_a
I find the conditions here hard to understand. Can we write it like this?
This does not explicitly exclude the ? true : false case, but that shouldn't be a problem.
Though checking for isa<Constant> here means that this transform will not work for vectors I think. It would be good to add a test for that and use a more general predicate.