[InstCombine] Fold logic-and/logic-or by distributive laws part2
authorchenglin.bi <chenglin.bi@linaro.org>
Mon, 9 Jan 2023 02:21:05 +0000 (10:21 +0800)
committerchenglin.bi <chenglin.bi@linaro.org>
Mon, 9 Jan 2023 02:21:17 +0000 (10:21 +0800)
commit33794cffcfdadfffda2c78c73a25ce6fc58596f0
treea86a9bae7ad03777cadcf73b2e17c9a1aa23a891
parente0e48187e6d8c395237964effe01205de138a708
[InstCombine] Fold logic-and/logic-or by distributive laws part2

Follow up https://reviews.llvm.org/D139408, support `and/or+select` patterns
X && Z || Y && Z --> (X || Y) && Z
https://alive2.llvm.org/ce/z/EMCkBG
https://alive2.llvm.org/ce/z/Q-YRvr
https://alive2.llvm.org/ce/z/SFkVQc
https://alive2.llvm.org/ce/z/S9MCuJ
https://alive2.llvm.org/ce/z/KZ7zzz

(X || Z) && (Y || Z) --> (X && Y) || Z
https://alive2.llvm.org/ce/z/Ggpa8-
https://alive2.llvm.org/ce/z/nhQRLY
https://alive2.llvm.org/ce/z/zpmEnq
https://alive2.llvm.org/ce/z/7omsrf
https://alive2.llvm.org/ce/z/CWBzBp

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D139630
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-factorize.ll