[llvm] [DAG] Constant Folding for U/SMUL_LOHI (PR #69437)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 02:17:33 PDT 2023


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 48a53509e851c93f352c967da1feb1c8fb2abd9a 55903f3580c9d337a308129332b3e548753cacaa -- 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/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 22798bbcd461..097bb8b968bb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -9880,14 +9880,14 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
            VTList.VTs[0] == Ops[1].getValueType() &&
            "Binary operator types must match!");
     // Constant fold.
-    ConstantSDNode* LHS = dyn_cast<ConstantSDNode>(Ops[0]);
-    ConstantSDNode* RHS = dyn_cast<ConstantSDNode>(Ops[1]);
-    if(LHS && RHS) {
+    ConstantSDNode *LHS = dyn_cast<ConstantSDNode>(Ops[0]);
+    ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(Ops[1]);
+    if (LHS && RHS) {
       unsigned Width = VTList.VTs[0].getScalarSizeInBits();
       unsigned OutWidth = Width * 2;
       APInt Val = LHS->getAPIntValue();
       APInt Mul = RHS->getAPIntValue();
-      if(Opcode == ISD::SMUL_LOHI) {
+      if (Opcode == ISD::SMUL_LOHI) {
         Val = Val.sext(OutWidth);
         Mul = Mul.sext(OutWidth);
       } else {
@@ -9896,7 +9896,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
       }
       Val *= Mul;
 
-      SDValue Hi = getConstant(Val.getHiBits(Width).trunc(Width), DL, VTList.VTs[0]);
+      SDValue Hi =
+          getConstant(Val.getHiBits(Width).trunc(Width), DL, VTList.VTs[0]);
       SDValue Lo = getConstant(Val.trunc(Width), DL, VTList.VTs[0]);
       return getNode(ISD::MERGE_VALUES, DL, VTList, {Lo, Hi}, Flags);
     }

``````````

</details>


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


More information about the llvm-commits mailing list