[llvm] 9f620b8 - [InstCombine] Slightly optimize visitFcmp (NFC) (#156097)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 31 08:49:00 PDT 2025


Author: Seraphimt
Date: 2025-08-31T17:48:56+02:00
New Revision: 9f620b8f62c4a0bdbf066c6f86ff9f38a6acd932

URL: https://github.com/llvm/llvm-project/commit/9f620b8f62c4a0bdbf066c6f86ff9f38a6acd932
DIFF: https://github.com/llvm/llvm-project/commit/9f620b8f62c4a0bdbf066c6f86ff9f38a6acd932.diff

LOG: [InstCombine] Slightly optimize visitFcmp (NFC) (#156097)

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

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Removed: 
    


################################################################################
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