[llvm] [DAG] isKnownNeverNaN - add DemandedElts element mask to isKnownNeverNaN calls (PR #135952)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 17 06:53:21 PDT 2025


================
@@ -5615,6 +5630,9 @@ bool SelectionDAG::isKnownNeverNaN(SDValue Op, bool SNaN, unsigned Depth) const
            (SNaN && !C->getValueAPF().isSignaling());
   }
 
+  if (!DemandedElts)
+    return false; // No demanded elts, better to assume we don't know anything.
----------------
LU-JOHN wrote:

> IIRC it's helped in strange edge cases but ideally we'd catch these in the caller.

If none of the current call-sites require a 0, I think it would be better to be strict now and use an assert.  Later if a call-site has a strange edge case that needs DemandedElts to be 0, the assert will force the caller to think carefully about why this is necessary and encourage them to create a testcase so that we know why we are allowing this. 

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


More information about the llvm-commits mailing list