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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 16 08:52:15 PDT 2024


================
@@ -1284,6 +1284,13 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
     return NewSub;
   }
 
+  // Fold (X + Y) / 2 --> (X & Y) iff (X u<= 1) && (Y u<= 1)
+  if (match(Op0, m_Add(m_Value(X), m_Value(Y))) && match(Op1, m_One()) &&
+      computeKnownBits(X, 0, &I).countMaxActiveBits() <= 1 &&
----------------
nikic wrote:

No compile-time impact.

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


More information about the llvm-commits mailing list