[llvm] [InstCombine] Optimize 'xor-and-select' sequence to 'or' for bool (PR #66394)

Qi Hu via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 14 11:03:27 PDT 2023


================
@@ -3202,6 +3202,14 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
     }
   }
 
+  // select (~b & a), a, b -> or a, b
+  // only for scalar types
+  if (match(CondVal, m_And(m_Not(m_Specific(FalseVal)), m_Specific(TrueVal))) &&
----------------
Qi-Hu wrote:

Good suggestions! I have included the pattern `select (~b | a), a, b`. The other two (`select (~a & b), a, b` and `select (~a | b), a, b`) are already simplified by the pass.

https://github.com/llvm/llvm-project/pull/66394


More information about the llvm-commits mailing list