[llvm] [RISCV][GlobalISel] Fold large constant offsets in selectAddrRegImm (PR #219161)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 02:53:37 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/RISCV/GISel/RISCVInstructionSelector.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/RISCV/GISel/RISCVInstructionSelector.cpp b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
index fdd681402..63ccf3dba 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
@@ -157,7 +157,7 @@ private:
 
   ComplexRendererFns renderVLOp(MachineOperand &Root) const;
   ComplexRendererFns renderAddiPair(Register BaseReg, int64_t AddiImm,
-                                   int64_t OffsetImm) const;
+                                    int64_t OffsetImm) const;
   // Custom renderers for tablegen
   void renderNegImm(MachineInstrBuilder &MIB, const MachineInstr &MI,
                     int OpIdx) const;
@@ -623,7 +623,7 @@ RISCVInstructionSelector::selectAddrRegImm(MachineOperand &Root) const {
     }
 
     // Large constant offset. Fold a -2048/2047 adjustment so the whole
-    // constant can be split across an ADDI and the load/store offset. 
+    // constant can be split across an ADDI and the load/store offset.
     if (RHSC >= -4096 && RHSC <= 4094) {
       int64_t Adj = RHSC < 0 ? -2048 : 2047;
       return renderAddiPair(LHS.getReg(), Adj, RHSC - Adj);

``````````

</details>


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


More information about the llvm-commits mailing list