[llvm] [InstCombine] Canonicalize fcmp with inf (PR #80986)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 06:51:45 PST 2024
================
@@ -7751,6 +7751,48 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
if (match(Op1, m_AnyZeroFP()) && !match(Op1, m_PosZeroFP()))
return replaceOperand(I, 1, ConstantFP::getZero(OpType));
+ // Canonicalize:
+ // fcmp olt X, +inf -> fcmp one X, +inf
+ // fcmp ole X, +inf -> fcmp ord X, 0
+ // fcmp ogt X, +inf -> false
+ // fcmp oge X, +inf -> fcmp oeq X, +inf
+ // fcmp ult X, +inf -> fcmp une X, +inf
+ // fcmp ule X, +inf -> true
+ // fcmp ugt X, +inf -> fcmp uno X, 0
+ // fcmp uge X, +inf -> fcmp ueq X, +inf
+ // fcmp olt X, -inf -> false
+ // fcmp ole X, -inf -> fcmp oeq X, -inf
+ // fcmp ogt X, -inf -> fcmp one X, -inf
+ // fcmp oge X, -inf -> fcmp ord X, 0
+ // fcmp ult X, -inf -> fcmp uno X, 0
+ // fcmp ule X, -inf -> fcmp ueq X, -inf
+ // fcmp ugt X, -inf -> fcmp une X, -inf
+ // fcmp uge X, -inf -> true
+ const APFloat *C;
+ if (match(Op1, m_APFloat(C)) && C->isInfinity()) {
+ switch (C->isNegative() ? FCmpInst::getSwappedPredicate(Pred) : Pred) {
+ default:
+ break;
+ case FCmpInst::FCMP_OGT:
----------------
dtcxzyw wrote:
Done.
https://github.com/llvm/llvm-project/pull/80986
More information about the llvm-commits
mailing list