[llvm] [InstCombine] Optimize redundant floating point comparisons in `or` inst (PR #158097)
Rajveer Singh Bharadwaj via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 13 04:02:52 PDT 2025
================
@@ -1850,6 +1850,26 @@ static Value *simplifyAndOrOfFCmps(const SimplifyQuery &Q, FCmpInst *LHS,
: ConstantInt::getBool(LHS->getType(), !IsAnd);
}
+ Value *V0;
+ const APFloat *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),
+ m_APFloat(V1Op1)))) {
+ if (V0Op1 > V1Op1)
+ return static_cast<Value *>(LHS);
----------------
Rajveer100 wrote:
I did that for consistency and making it clear what we are returning.
https://github.com/llvm/llvm-project/pull/158097
More information about the llvm-commits
mailing list