[llvm] [SelectionDAG] Deal with POISON for INSERT_VECTOR_ELT/INSERT_SUBVECTOR (part 1) (PR #143102)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 02:58:27 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 cpp -- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 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/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index a52edca64..7490f288e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -27373,11 +27373,11 @@ SDValue DAGCombiner::visitINSERT_SUBVECTOR(SDNode *N) {
 
   // If inserting an UNDEF, just return the original vector (unless it makes the
   // result more poisonous).
-  if (N1.isUndef()){
+  if (N1.isUndef()) {
     if (VT.isFixedLengthVector()) {
       unsigned SubVecNumElts = N1.getValueType().getVectorNumElements();
-      APInt EltMask = APInt::getBitsSet(VT.getVectorNumElements(),
-                                        InsIdx, InsIdx + SubVecNumElts);
+      APInt EltMask = APInt::getBitsSet(VT.getVectorNumElements(), InsIdx,
+                                        InsIdx + SubVecNumElts);
       if (DAG.isGuaranteedNotToBePoison(N0, EltMask))
         return N0;
     } else if (DAG.isGuaranteedNotToBePoison(N0))
@@ -27398,8 +27398,8 @@ SDValue DAGCombiner::visitINSERT_SUBVECTOR(SDNode *N) {
         return N1.getOperand(0);
       if (VT.isFixedLengthVector() && N1VT.isFixedLengthVector()) {
         unsigned SubVecNumElts = N1VT.getVectorNumElements();
-        APInt EltMask = APInt::getBitsSet(VT.getVectorNumElements(),
-                                          InsIdx, InsIdx + SubVecNumElts);
+        APInt EltMask = APInt::getBitsSet(VT.getVectorNumElements(), InsIdx,
+                                          InsIdx + SubVecNumElts);
         if (DAG.isGuaranteedNotToBePoison(N1.getOperand(0), ~EltMask))
           return N1.getOperand(0);
       } else if (DAG.isGuaranteedNotToBePoison(N1.getOperand(0)))
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 6bff2d90b..300881f38 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -7920,8 +7920,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
     // But not if skipping the insert could make the result more poisonous.
     if (N2.isUndef()) {
       if (N3C && VT.isFixedLengthVector()) {
-        APInt EltMask = APInt::getOneBitSet(VT.getVectorNumElements(),
-                                            N3C->getZExtValue());
+        APInt EltMask =
+            APInt::getOneBitSet(VT.getVectorNumElements(), N3C->getZExtValue());
         if (isGuaranteedNotToBePoison(N1, EltMask))
           return N1;
       } else if (isGuaranteedNotToBePoison(N1))
@@ -7974,8 +7974,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
       if (VT.isFixedLengthVector() && N2VT.isFixedLengthVector()) {
         unsigned LoBit = N3->getAsZExtVal();
         unsigned HiBit = LoBit + N2VT.getVectorNumElements();
-        APInt EltMask = APInt::getBitsSet(VT.getVectorNumElements(),
-                                          LoBit, HiBit);
+        APInt EltMask =
+            APInt::getBitsSet(VT.getVectorNumElements(), LoBit, HiBit);
         if (isGuaranteedNotToBePoison(N2.getOperand(0), ~EltMask))
           return N2.getOperand(0);
       } else if (isGuaranteedNotToBePoison(N2.getOperand(0)))
@@ -7988,8 +7988,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
       if (VT.isFixedLengthVector()) {
         unsigned LoBit = N3->getAsZExtVal();
         unsigned HiBit = LoBit + N2VT.getVectorNumElements();
-        APInt EltMask = APInt::getBitsSet(VT.getVectorNumElements(),
-                                          LoBit, HiBit);
+        APInt EltMask =
+            APInt::getBitsSet(VT.getVectorNumElements(), LoBit, HiBit);
         if (isGuaranteedNotToBePoison(N1, EltMask))
           return N1;
       } else if (isGuaranteedNotToBePoison(N1))

``````````

</details>


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


More information about the llvm-commits mailing list