[InstCombine] generalize select + select/and/or folding using implied conditions
This patch optimizes the remaining possible cases in D101191 by generalizing isImpliedCondition()-based foldings. Assume that there is `op a, (select b, _, _)` where op is one of `and i1`, `or i1` or their select forms. We can do the following optimization based on the result of `isImpliedCondition(a, b)`: If a = true implies… - b = true: - select a, (select b, A, B), false => select a, A, false : https://alive2.llvm.org/ce/z/WCnZYh - and a, (select b, A, B) => select a, A, false : https://alive2.llvm.org/ce/z/uZhcMG - b = false: - select a, (select b, A, B), false => select a, B, false : https://alive2.llvm.org/ce/z/c2hJpV - and a, (select b, A, B) => select a, B, false : https://alive2.llvm.org/ce/z/5ggwMM If a = false implies… - b = true: - select a, true, (select b, A, B) => select a, true, A : https://alive2.llvm.org/ce/z/tidKvH - or a, (select b, A, B) => select a, true, A : https://alive2.llvm.org/ce/z/cC-uyb - b = false: - select a, true, (select b, A, B) => select a, true, B : https://alive2.llvm.org/ce/z/ZXpJq9 - or a, (select b, A, B) => select a, true, B : https://alive2.llvm.org/ce/z/hnDrJj Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D101720
Loading
Please sign in to comment