[llvm] Minor optimaze in visitFcmp (PR #156097)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 29 13:20:38 PDT 2025


https://github.com/Seraphimt created https://github.com/llvm/llvm-project/pull/156097

Studying the code related to float found a slightly optimal sequence of actions.

>From ef626553cad7cab002f4c99505121b830cccbc7a Mon Sep 17 00:00:00 2001
From: Seraphimt <svet58585 at mail.ru>
Date: Fri, 29 Aug 2025 22:51:36 +0300
Subject: [PATCH] minor optimaze by rearranged line

---
 llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 3a8e043038153..90feddf6dcfe1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -8944,14 +8944,14 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
   }
 
   {
-    Value *CanonLHS = nullptr, *CanonRHS = nullptr;
+    Value *CanonLHS = nullptr;
     match(Op0, m_Intrinsic<Intrinsic::canonicalize>(m_Value(CanonLHS)));
-    match(Op1, m_Intrinsic<Intrinsic::canonicalize>(m_Value(CanonRHS)));
-
     // (canonicalize(x) == x) => (x == x)
     if (CanonLHS == Op1)
       return new FCmpInst(Pred, Op1, Op1, "", &I);
 
+    Value *CanonRHS = nullptr;
+    match(Op1, m_Intrinsic<Intrinsic::canonicalize>(m_Value(CanonRHS)));
     // (x == canonicalize(x)) => (x == x)
     if (CanonRHS == Op0)
       return new FCmpInst(Pred, Op0, Op0, "", &I);



More information about the llvm-commits mailing list