[llvm] [InstCombine] Optimize redundant floating point comparisons in `or`/`and` inst's (PR #158097)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 13 04:33:23 PDT 2025
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/Analysis/InstructionSimplify.cpp
``````````
: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/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index eff374064..795f1aee4 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1852,10 +1852,11 @@ static Value *simplifyAndOrOfFCmps(const SimplifyQuery &Q, FCmpInst *LHS,
Value *V0;
const APFloat *V0Op1, *V1Op1;
- // (fcmp olt V0, V0Op1) || (fcmp olt V0, V1Op1) --> fcmp olt V0, max(V0Op1, V1Op1)
- // (fcmp ogt V0, V0Op1) || (fcmp ogt V0, V1Op1) --> fcmp ogt V0, max(V0Op1, V1Op1)
- // (fcmp olt V0, V0Op1) && (fcmp olt V0, V1Op1) --> fcmp olt V0, min(V0Op1, V1Op1)
- // (fcmp ogt V0, V0Op1) && (fcmp ogt V0, V1Op1) --> fcmp ogt V0, min(V0Op1, V1Op1)
+ // (fcmp olt V0, V0Op1) || (fcmp olt V0, V1Op1) --> fcmp olt V0, max(V0Op1,
+ // V1Op1) (fcmp ogt V0, V0Op1) || (fcmp ogt V0, V1Op1) --> fcmp ogt V0,
+ // max(V0Op1, V1Op1) (fcmp olt V0, V0Op1) && (fcmp olt V0, V1Op1) --> fcmp olt
+ // V0, min(V0Op1, V1Op1) (fcmp ogt V0, V0Op1) && (fcmp ogt V0, V1Op1) --> fcmp
+ // ogt V0, min(V0Op1, V1Op1)
if (match(LHS, m_SpecificFCmp(FCmpInst::FCMP_OLT, m_Value(V0),
m_APFloat(V0Op1))) &&
match(RHS, m_SpecificFCmp(FCmpInst::FCMP_OLT, m_Specific(V0),
``````````
</details>
https://github.com/llvm/llvm-project/pull/158097
More information about the llvm-commits
mailing list