[llvm] [InstCombine]combine mul(abs(x), abs(y)) to abs(mul(x, y)) (PR #78395)

Congcong Cai via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 05:59:49 PST 2024


================
@@ -330,6 +330,18 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
       return BinaryOperator::CreateMul(X, X);
   }
 
+  {
+    Value *X, *Y;
+    // abs(X) * abs(Y) -> abs(X * Y)
+    if (I.hasNoSignedWrap() &&
+        match(Op0, m_Intrinsic<Intrinsic::abs>(m_Value(X), m_AllOnes())) &&
+        match(Op1, m_Intrinsic<Intrinsic::abs>(m_Value(Y), m_AllOnes())))
----------------
HerrCai0907 wrote:

Done. Thanks!

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


More information about the llvm-commits mailing list