[llvm] [Mips] Add 'j' alias for r6 (PR #196706)

via llvm-commits llvm-commits at lists.llvm.org
Sat May 9 02:19:44 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-mips

Author: yingopq

<details>
<summary>Changes</summary>

Fix #<!-- -->107460.

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


2 Files Affected:

- (modified) llvm/lib/Target/Mips/MipsInstrInfo.td (+3-1) 
- (added) llvm/test/MC/Mips/j-alias-r6.s (+10) 


``````````diff
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td
index 76bfe31534161..fabf812c9d1a8 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.td
@@ -2747,7 +2747,9 @@ let AdditionalPredicates = [NotInMicroMips] in {
   def : MipsInstAlias<"bal $offset", (BGEZAL ZERO, brtarget:$offset), 1>,
         ISA_MIPS1_NOT_32R6_64R6;
 
-  def : MipsInstAlias<"j $rs", (JR GPR32Opnd:$rs), 0>, ISA_MIPS1;
+  def : MipsInstAlias<"j $rs", (JR GPR32Opnd:$rs), 0>, ISA_MIPS1_NOT_32R6_64R6;
+
+  def : MipsInstAlias<"j $rs", (JALR RA, GPR32Opnd:$rs), 0>, ISA_MIPS32R6;
 
   def : MipsInstAlias<"jalr $rs", (JALR RA, GPR32Opnd:$rs), 0>;
 
diff --git a/llvm/test/MC/Mips/j-alias-r6.s b/llvm/test/MC/Mips/j-alias-r6.s
new file mode 100644
index 0000000000000..720b4f936cfbd
--- /dev/null
+++ b/llvm/test/MC/Mips/j-alias-r6.s
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple mips-unknown-linux-gnu -show-inst --mcpu=mips32r5 %s \
+# RUN:   | FileCheck --check-prefix=R5 %s
+# RUN: llvm-mc -triple mips-unknown-linux-gnu -show-inst --mcpu=mips32r6 %s \
+# RUN:   | FileCheck --check-prefix=R6 %s
+
+  .text
+  j $ra
+
+# R5:    jr $ra
+# R6:    jalr $ra

``````````

</details>


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


More information about the llvm-commits mailing list