[llvm] IR: introduce CmpInst::is{Eq,Ne}Equivalence (PR #111979)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 04:01:50 PDT 2024


================
@@ -3471,6 +3471,63 @@ 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. If both operands are constants, simply return the
+// equality of the constants.
+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) {
----------------
arsenm wrote:

This is essentially m_AnyZeroFP 

https://github.com/llvm/llvm-project/pull/111979


More information about the llvm-commits mailing list