[llvm] [InstCombine] Add fold for fabs(-x) -> fabs(x) (PR #94183)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 02:05:43 PDT 2024
================
@@ -2517,6 +2517,13 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
}
case Intrinsic::fabs: {
Value *Cond, *TVal, *FVal;
+ Value* Arg = II->getArgOperand(0);
+ Value* X;
+ // fabs (-X) --> fabs (X)
+ if (match(Arg, m_FNeg(m_Value(X)))) {
----------------
dtcxzyw wrote:
Please drop the braces.
See https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
https://github.com/llvm/llvm-project/pull/94183
More information about the llvm-commits
mailing list