[llvm] [SelectionDAG] Fix isKnownNeverZeroFloat for vectors (PR #78308)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 09:28:15 PST 2024


================
@@ -5239,14 +5239,11 @@ bool SelectionDAG::isKnownNeverZeroFloat(SDValue Op) const {
   // Return false if we find any zero in a vector.
   if (Op->getOpcode() == ISD::BUILD_VECTOR ||
       Op->getOpcode() == ISD::SPLAT_VECTOR) {
-    for (const SDValue &OpVal : Op->op_values()) {
-      if (OpVal.isUndef())
-        return false;
+    return llvm::all_of(Op->op_values(), [](const SDValue &OpVal){
       if (auto *C = dyn_cast<ConstantFPSDNode>(OpVal))
-        if (C->isZero())
-          return false;
-    }
-    return true;
+        return !C->isZero();
+      return false;
----------------
RKSimon wrote:

You might be able to do this with matchUnaryFpPredicate

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


More information about the llvm-commits mailing list