[llvm] [InstCombine] Fold abs(a * abs(b)) --> abs(a * b) (PR #78110)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 11:31:08 PST 2024
================
@@ -1601,6 +1601,15 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
return CastInst::Create(Instruction::ZExt, NarrowAbs, II->getType());
}
+ // abs(a * abs(b)) --> abs(a * b)
+ Value *A, *B;
+ if (match(IIOperand,
+ m_OneUse(m_c_Mul(m_Value(A),
+ m_Intrinsic<Intrinsic::abs>(m_Value(B)))))) {
+ Value *New = Builder.CreateMul(A, B);
----------------
goldsteinn wrote:
You can propagate `nsw` to the new mul: https://alive2.llvm.org/ce/z/WjjNFF
https://github.com/llvm/llvm-project/pull/78110
More information about the llvm-commits
mailing list