[llvm] [SelectionDAG] Improve isGuaranteedNotToBeUndefOrPoison (PR #147019)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 4 01:58:48 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- llvm/include/llvm/CodeGen/SelectionDAGNodes.h llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 107014465..5f7eb7b66 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5529,9 +5529,8 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
     if (DemandedElts.ugt(1) && !PoisonOnly)
       return false;
     // Check element zero.
-    if (DemandedElts[0] && !isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0),
-                                                             PoisonOnly,
-                                                             Depth + 1))
+    if (DemandedElts[0] && !isGuaranteedNotToBeUndefOrPoison(
+                               Op.getOperand(0), PoisonOnly, Depth + 1))
       return false;
     return true;
 
@@ -5564,8 +5563,8 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
     // enough to check operand 0 if Op can't create undef/poison.
     return !canCreateUndefOrPoison(Op, DemandedElts, PoisonOnly,
                                    /*ConsiderFlags*/ true, Depth) &&
-        isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), DemandedElts,
-                                         PoisonOnly, Depth + 1);
+           isGuaranteedNotToBeUndefOrPoison(Op.getOperand(0), DemandedElts,
+                                            PoisonOnly, Depth + 1);
 
   case ISD::BSWAP:
   case ISD::CTPOP:
@@ -5598,9 +5597,9 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
     return !canCreateUndefOrPoison(Op, DemandedElts, PoisonOnly,
                                    /*ConsiderFlags*/ true, Depth) &&
            all_of(Op->ops(), [&](SDValue V) {
-               return isGuaranteedNotToBeUndefOrPoison(V, DemandedElts,
-                                                       PoisonOnly, Depth + 1);
-             });
+             return isGuaranteedNotToBeUndefOrPoison(V, DemandedElts,
+                                                     PoisonOnly, Depth + 1);
+           });
   }
 
     // TODO: Search for noundef attributes from library functions.

``````````

</details>


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


More information about the llvm-commits mailing list