[llvm] IR: introduce CmpInst::is{Eq,Ne}Equivalence (PR #111979)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 11 05:13:50 PDT 2024
================
@@ -3472,30 +3473,20 @@ bool CmpInst::isEquality(Predicate P) {
}
// Returns true if either operand of CmpInst is a provably non-zero
-// floating-point constant. If both operands are constants, simply return the
-// equality of the constants.
+// floating-point constant.
static bool hasNonZeroFPOperands(const CmpInst *Cmp) {
auto *LHS = dyn_cast<Constant>(Cmp->getOperand(0));
auto *RHS = dyn_cast<Constant>(Cmp->getOperand(1));
- if (LHS && RHS)
- return LHS == RHS;
if (auto *Const = LHS ? LHS : RHS) {
- if (auto *ConstFP = dyn_cast<ConstantFP>(Const)) {
- if (!ConstFP->isZero())
- return true;
- } else if (auto *ConstVec = dyn_cast<ConstantVector>(Const)) {
- if (auto *SplatCFP =
- dyn_cast_or_null<ConstantFP>(ConstVec->getSplatValue())) {
- if (!SplatCFP->isZero())
- return true;
- }
- }
+ using namespace llvm::PatternMatch;
+ return Const->isNormalFP() && match(Const, m_NonZeroFP());
----------------
arsenm wrote:
Redundant handling, and confusing to split the FP predicate. Infinities are also not complicated
https://github.com/llvm/llvm-project/pull/111979
More information about the llvm-commits
mailing list