[llvm] [InstCombine] Fold `fcmp (fmul X, C1), C2` to `fcmp X, C2/C1` (PR #205003)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 11 11:25:11 PDT 2026


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 origin/main HEAD --extensions cpp -- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index f8fd1fff5..be1328df8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -8889,18 +8889,17 @@ static Instruction *foldFCmpFmulIntoFCmp(FCmpInst &I, Instruction *LHSI,
     return nullptr;
 
   const APFloat *C1, *C2;
-  if (!match(LHSI->getOperand(1), m_APFloat(C1)) ||
-      !match(RHSC, m_APFloat(C2)))
+  if (!match(LHSI->getOperand(1), m_APFloat(C1)) || !match(RHSC, m_APFloat(C2)))
     return nullptr;
 
   Type *FPTy = LHSI->getType()->getScalarType();
   if (I.getFunction()->getDenormalMode(FPTy->getFltSemantics()) !=
-          DenormalMode::getIEEE())
+      DenormalMode::getIEEE())
     return nullptr;
 
   if (C1->isNegative())
     Pred = I.getSwappedPredicate();
-  
+
   APFloat C = *C2;
   if (C.divide(*C1, RoundingMode::NearestTiesToEven) != APFloat::opOK)
     return nullptr;

``````````

</details>


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


More information about the llvm-commits mailing list