[llvm] IR: introduce CmpInst::isEquivalence (PR #111979)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 05:29:08 PDT 2024
================
@@ -3471,6 +3472,44 @@ bool CmpInst::isEquality(Predicate P) {
llvm_unreachable("Unsupported predicate kind");
}
+// Returns true if either operand of CmpInst is a provably non-zero
+// 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 (auto *Const = LHS ? LHS : RHS) {
+ using namespace llvm::PatternMatch;
+ return match(Const, m_NonZeroNotDenormalFP());
+ }
+ return false;
+}
+
+// Floating-point equality is not an equivalence when comparing +0.0 with
+// -0.0, when comparing NaN with another value, or when flushing
+// denormals-to-zero.
+bool CmpInst::isEquivalence(bool Invert) const {
----------------
nikic wrote:
For Invert=true you should invert the predicate, instead of duplicating the checks.
https://github.com/llvm/llvm-project/pull/111979
More information about the llvm-commits
mailing list