[PATCH] D126040: [InstCombine] Fold a mul with bool value into and

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 00:37:54 PDT 2022


Allen added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:382-383
+  // rather than -X & Y, but it's increasing the count either way.)
+  if (match(Op0, m_And(m_Value(X), m_One())) &&
+      match(Op1, m_And(m_Value(Y), m_One())))
+    return BinaryOperator::CreateAnd(Op0, Op1);
----------------
spatel wrote:
> Don't capture X and Y if we are not using them in the new instruction.
Thanks @spatel very much, as the m_And operation need 2 operands. How can I not match the 1st operand?
Do you mean use  the **Op0->gtOpcode() == Instruction::And && isOneConstant(Op0->getOperand(1))** ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126040/new/

https://reviews.llvm.org/D126040



More information about the llvm-commits mailing list