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

Danila Malyutin via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 10:25:47 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;
----------------
danilaml wrote:

Nice. Didn't know about it. I hope I used it correctly.

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


More information about the llvm-commits mailing list