[llvm] [PowerPC] Generalize combineADDToADDZE to support i32 operands (PR #207553)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 19:00:10 PDT 2026


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 origin/main HEAD --extensions cpp -- llvm/lib/Target/PowerPC/PPCISelLowering.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 949e3de8a..142fb462a 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -20068,7 +20068,7 @@ static SDValue combineADDToADDZE(SDNode *N, SelectionDAG &DAG,
 
   if (Z.getValueType() != NativeVT)
     Z = DAG.getNode(ISD::SIGN_EXTEND, DL, NativeVT, Z);
-  
+
   SDValue ExtLHS = LHS;
   if (ExtLHS.getValueType() != NativeVT)
     ExtLHS = DAG.getNode(ISD::SIGN_EXTEND, DL, NativeVT, ExtLHS);
@@ -20087,13 +20087,14 @@ static SDValue combineADDToADDZE(SDNode *N, SelectionDAG &DAG,
     //                            \    when -32768 <= -C <= 32767 && C != 0
     //                             --> addze X, (addic (addi Z, -C), -1).carry
     SDValue Add = DAG.getNode(ISD::ADD, DL, NativeVT, Z,
-                              DAG.getConstant(NativeVT == MVT::i32 ? (uint32_t)NegConstant : (uint64_t)NegConstant,
+                              DAG.getConstant(NativeVT == MVT::i32
+                                                  ? (uint32_t)NegConstant
+                                                  : (uint64_t)NegConstant,
                                               DL, NativeVT));
     SDValue AddOrZ = NegConstant != 0 ? Add : Z;
-    SDValue Addc =
-        DAG.getNode(ISD::UADDO_CARRY, DL, VTs,
-                    AddOrZ, DAG.getAllOnesConstant(DL, NativeVT),
-                    DAG.getConstant(0, DL, CarryType));
+    SDValue Addc = DAG.getNode(ISD::UADDO_CARRY, DL, VTs, AddOrZ,
+                               DAG.getAllOnesConstant(DL, NativeVT),
+                               DAG.getConstant(0, DL, CarryType));
     Result = DAG.getNode(ISD::UADDO_CARRY, DL, VTs, ExtLHS,
                          DAG.getConstant(0, DL, NativeVT),
                          SDValue(Addc.getNode(), 1));
@@ -20107,13 +20108,14 @@ static SDValue combineADDToADDZE(SDNode *N, SelectionDAG &DAG,
     //                            \    when -32768 <= -C <= 32767 && C != 0
     //                             --> addze X, (subfic (addi Z, -C), 0).carry
     SDValue Add = DAG.getNode(ISD::ADD, DL, NativeVT, Z,
-                              DAG.getConstant(NativeVT == MVT::i32 ? (uint32_t)NegConstant : (uint64_t)NegConstant,
+                              DAG.getConstant(NativeVT == MVT::i32
+                                                  ? (uint32_t)NegConstant
+                                                  : (uint64_t)NegConstant,
                                               DL, NativeVT));
     SDValue AddOrZ = NegConstant != 0 ? Add : Z;
     SDValue Subc =
-        DAG.getNode(ISD::USUBO_CARRY, DL, VTs,
-                    DAG.getConstant(0, DL, NativeVT), AddOrZ,
-                    DAG.getConstant(0, DL, CarryType));
+        DAG.getNode(ISD::USUBO_CARRY, DL, VTs, DAG.getConstant(0, DL, NativeVT),
+                    AddOrZ, DAG.getConstant(0, DL, CarryType));
     SDValue Invert = DAG.getNode(ISD::XOR, DL, CarryType, Subc.getValue(1),
                                  DAG.getConstant(1UL, DL, CarryType));
     Result = DAG.getNode(ISD::UADDO_CARRY, DL, VTs, ExtLHS,

``````````

</details>


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


More information about the llvm-commits mailing list