[llvm] [InstCombine] Generalize ignoreSignBitOfZero/NaN to handle more cases (PR #141015)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu May 22 02:46:30 PDT 2025


================
@@ -2803,15 +2830,70 @@ static bool ignoreSignBitOfNaN(Instruction &I) {
   if (!I.hasOneUse())
     return false;
   Instruction *User = I.user_back();
+  if (auto *FPOp = dyn_cast<FPMathOperator>(User)) {
+    if (FPOp->hasNoNaNs())
+      return true;
+  }
 
-  // fcmp ignores the sign bit of NaN.
-  if (User->getOpcode() == Instruction::FCmp)
+  switch (User->getOpcode()) {
----------------
arsenm wrote:

Maybe this should go into a utility function in lib/Analysis

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


More information about the llvm-commits mailing list