[llvm] [InstCombine] Add fold for fabs(-x) -> fabs(x) (PR #95627)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 01:29:29 PDT 2024
================
@@ -2514,9 +2514,11 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
Value* Arg = II->getArgOperand(0);
Value* X;
// fabs (-X) --> fabs (X)
- if (match(Arg, m_FNeg(m_Value(X))))
- return replaceInstUsesWith(
- CI, Builder.CreateUnaryIntrinsic(Intrinsic::fabs, X));
+ if (match(Arg, m_FNeg(m_Value(X)))) {
+ CallInst *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, X);
+ Fabs->copyFastMathFlags(II);
----------------
VaibhavRumale wrote:
Changed the code to pass II as the 3rd argument to CreateUnaryIntrinsic. Made necessary adjustments
https://github.com/llvm/llvm-project/pull/95627
More information about the llvm-commits
mailing list