[llvm] [Mips] Restrict microMIPS GP load folding to word loads (PR #228881)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 05:42:15 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-mips

Author: Jiaxun Yang (FlyGoat)

<details>
<summary>Changes</summary>

Only LW has a GP-relative variant, so restrict the folding to LW_MM and
LW_MMR6.

Assisted-by: OpenAI Codex # Testcases


Validation: `git diff --check` passes. Tests were not rerun for this cherry-pick.


---
Full diff: https://github.com/llvm/llvm-project/pull/228881.diff


1 Files Affected:

- (modified) llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 48163a54f4837..18cb00b9fd28b 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -2135,7 +2135,7 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
   }
 
   if (inMicroMipsMode()) {
-    if (MCID.mayLoad() && Opcode != Mips::LWP_MM) {
+    if (Opcode == Mips::LW_MM || Opcode == Mips::LW_MMR6) {
       // Try to create 16-bit GP relative load instruction.
       for (unsigned i = 0; i < MCID.getNumOperands(); i++) {
         const MCOperandInfo &OpInfo = MCID.operands()[i];

``````````

</details>


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


More information about the llvm-commits mailing list