[llvm] [RISCV] Combine (ADDI (ADDI X, C1), C2) -> (ADDI X, C1+C2) (PR #157416)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 03:16:20 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 origin/main HEAD --extensions cpp -- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/Target/RISCV/RISCVISelLowering.cpp
``````````

: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/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 56e273c8d..e2d9adecd 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -4019,7 +4019,7 @@ void SelectionDAGBuilder::visitBitCast(const User &I) {
   // constant integer as an opaque constant.
   else if(ConstantInt *C = dyn_cast<ConstantInt>(I.getOperand(0)))
     setValue(&I, DAG.getConstant(C->getValue(), dl, DestVT, /*isTarget=*/false,
-                                 /*isOpaque*/false));
+                                 /*isOpaque*/ false));
   else
     setValue(&I, N);            // noop cast.
 }
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 7d77535fb..323352eb5 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -9424,7 +9424,8 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {
         SDValue SubOp;
         using namespace llvm::SDPatternMatch;
         SDValue ShAmt;
-        if (sd_match(RegV, m_OneUse(m_Not(m_OneUse(m_Shl(m_AllOnes(), m_Value(ShAmt))))))) {
+        if (sd_match(RegV, m_OneUse(m_Not(m_OneUse(
+                               m_Shl(m_AllOnes(), m_Value(ShAmt))))))) {
           SDValue One = DAG.getConstant(1, DL, VT);
           SDValue Shl = DAG.getNode(ISD::SHL, DL, VT, One, ShAmt);
           SDValue SubAmt = DAG.getConstant(1 + RawConstVal, DL, VT);

``````````

</details>


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


More information about the llvm-commits mailing list