[llvm] [InstCombine] simplify average of lsb (PR #95684)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 15 20:17:51 PDT 2024


================
@@ -1284,6 +1284,14 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
     return NewSub;
   }
 
+  // ((X % 2) + (Y % 2)) / 2 --> (X & Y & 1)
+  if (match(Op0,
+            m_Add(m_And(m_Value(X), m_One()), m_And(m_Value(Y), m_One()))) &&
----------------
dtcxzyw wrote:

No. Please use `computeKnownBits(...).countMaxActiveBits() <= 1`.


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


More information about the llvm-commits mailing list