[llvm] [DAGCombiner] Add combine avg from shifts (PR #113909)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 06:42:09 PDT 2024


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 9090430d4176fa260b8da46b7b983b3760d452be bdc19e51de17e35bd6d123dda72eba4824cdcc70 --extensions cpp -- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/lib/Target/ARM/ARMISelLowering.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 125e822ddd..a7a1a38444 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5359,12 +5359,17 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
   // Fold avgfloor((add nw x,y), 1) -> avgceil(x,y)
   if (Opcode == ISD::AVGFLOORU || Opcode == ISD::AVGFLOORS) {
     SDValue Add;
-    if(sd_match(N, m_c_BinOp(Opcode, m_AllOf(m_Value(Add), m_Add(m_Value(X), m_Value(Y))), m_One()))) {
+    if (sd_match(N,
+                 m_c_BinOp(Opcode,
+                           m_AllOf(m_Value(Add), m_Add(m_Value(X), m_Value(Y))),
+                           m_One()))) {
       if (IsSigned) {
-        if (hasOperation(ISD::AVGCEILS, VT) && Add->getFlags().hasNoSignedWrap())
+        if (hasOperation(ISD::AVGCEILS, VT) &&
+            Add->getFlags().hasNoSignedWrap())
           return DAG.getNode(ISD::AVGCEILS, DL, VT, X, Y);
-        } else if (hasOperation(ISD::AVGCEILU, VT) && Add->getFlags().hasNoUnsignedWrap())
-          return DAG.getNode(ISD::AVGCEILU, DL, VT, X, Y);
+      } else if (hasOperation(ISD::AVGCEILU, VT) &&
+                 Add->getFlags().hasNoUnsignedWrap())
+        return DAG.getNode(ISD::AVGCEILU, DL, VT, X, Y);
     }
   }
 
@@ -11459,8 +11464,7 @@ SDValue DAGCombiner::combineAVG(SDNode *N) {
   if (!IsUnsigned && !Add->getFlags().hasNoSignedWrap())
     return SDValue();
 
-  return DAG.getNode(FloorISD, SDLoc(N), N->getValueType(0),
-                     {A, B});
+  return DAG.getNode(FloorISD, SDLoc(N), N->getValueType(0), {A, B});
 }
 
 /// Generate Min/Max node

``````````

</details>


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


More information about the llvm-commits mailing list