[llvm] InstCombine: fold(select C, (X | A), X) | B into X | select C, (A | B), B. (#154246) (PR #154267)
Rohan A M via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 07:39:17 PDT 2025
================
@@ -2695,6 +2695,40 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I))
return FoldedLogic;
+ // Factor a common operand across select feeding an 'or':
----------------
badwriter123 wrote:
Hello,
while working on the optimization for the OR operation , I rewrite the expression from (select C, (X | A), X) | B to select C, (A | B),B. The same OR optimization can be used to rewrite AND operations as well. Instead of overengineering , I thought of duplicating it for AND operations.
if not required for AND operations, the code can be discarded.
https://github.com/llvm/llvm-project/pull/154267
More information about the llvm-commits
mailing list