[llvm] [InstCombine] Handle isnormal idiom (PR #125454)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 2 20:34:08 PST 2025
================
@@ -3500,6 +3500,22 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
}
}
+ // (X & ExpMask) != 0 && (X & ExpMask) != ExpMask -> isnormal(X)
+ // (X & ExpMask) == 0 || (X & ExpMask) == ExpMask -> !isnormal(X)
+ Value *X;
+ const APInt *MaskC;
+ if (LHS0 == RHS0 && PredL == PredR &&
+ PredL == (IsAnd ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ) &&
+ !I.getFunction()->hasFnAttribute(Attribute::NoImplicitFloat) &&
+ match(LHS0, m_And(m_ElementWiseBitCast(m_Value(X)), m_APInt(MaskC))) &&
+ X->getType()->getScalarType()->isIEEELikeFPTy() &&
+ APFloat(X->getType()->getScalarType()->getFltSemantics(), *MaskC)
----------------
arsenm wrote:
Needs hasOneUse checks?
https://github.com/llvm/llvm-project/pull/125454
More information about the llvm-commits
mailing list