[llvm] [DAG] Lower frem of power-2 using div/trunc/mul+sub (PR #91148)

David Green via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 04:36:22 PDT 2024


================
@@ -5567,7 +5567,7 @@ bool SelectionDAG::isKnownNeverZero(SDValue Op, unsigned Depth) const {
 
 bool SelectionDAG::isKnownNonNegativeFP(SDValue Op) const {
   if (ConstantFPSDNode *C1 = isConstOrConstSplatFP(Op, true))
-    return !C1->isNegative();
+    return !C1->isNegative() && !C1->isNaN();
----------------
davemgreen wrote:

Yeah I was thinking about this. For the point of view of the frem fold it seems that -Nan is fine in either case. I'm happy for the function to return true for -Nan, it would be fine either way.

For the function in general - it is for fp detecting whether the value is known to be positive (it could be called isKnownPositiveFP?). Returning positive NaN is probably fine for the moment, and then if we need to change it in the future it could be made an option or an extra function call to rule out NaN's.

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


More information about the llvm-commits mailing list