[llvm] [InstCombine] Add fold for fabs(-x) -> fabs(x) (PR #95627)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 21:42:00 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff cfbed2c0e6110878e6174067e2fb8013fc512620 bc5a50fe78ce88d7ab24c8bda945deee630da426 -- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 71af5eca43..c21514481a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2511,12 +2511,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
   }
   case Intrinsic::fabs: {
     Value *Cond, *TVal, *FVal;
-    Value* Arg = II->getArgOperand(0);
-    Value* X;
+    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));
+      return replaceInstUsesWith(
+          CI, Builder.CreateUnaryIntrinsic(Intrinsic::fabs, X));
 
     if (match(Arg, m_Select(m_Value(Cond), m_Value(TVal), m_Value(FVal)))) {
       // fabs (select Cond, TrueC, FalseC) --> select Cond, AbsT, AbsF

``````````

</details>


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


More information about the llvm-commits mailing list