[llvm] 4639fa2 - [Mips] Mark immediate branch macros as having delay slots (#217565)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 23 18:37:23 PDT 2026
Author: Jiaxun Yang
Date: 2026-08-24T09:37:18+08:00
New Revision: 4639fa213220d55af5d6824924676af02fd03bf8
URL: https://github.com/llvm/llvm-project/commit/4639fa213220d55af5d6824924676af02fd03bf8
DIFF: https://github.com/llvm/llvm-project/commit/4639fa213220d55af5d6824924676af02fd03bf8.diff
LOG: [Mips] Mark immediate branch macros as having delay slots (#217565)
Immediate conditional branch macros expand to real branches with delay
slots, but their pseudo-instruction definitions did not carry
`hasDelaySlot`. Mark them consistently with the register forms so IAS
inserts a delay-slot `nop` under `.set reorder`.
Adds `llvm/test/MC/Mips/macro-bcc-imm-delay-slot.s` covering reordered
and non-reordered expansion.
Fixes #217368
Added:
llvm/test/MC/Mips/macro-bcc-imm-delay-slot.s
Modified:
llvm/lib/Target/Mips/MipsInstrInfo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td
index 2b21fe74eaf12..9448c33888a5b 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.td
@@ -3025,7 +3025,7 @@ def BLEUL: CondBranchPseudo<"bleul">, ISA_MIPS2_NOT_32R6_64R6;
def BGEUL: CondBranchPseudo<"bgeul">, ISA_MIPS2_NOT_32R6_64R6;
def BGTUL: CondBranchPseudo<"bgtul">, ISA_MIPS2_NOT_32R6_64R6;
-let isCTI = 1 in
+let hasDelaySlot = 1, isCTI = 1 in
class CondBranchImmPseudo<string instr_asm> :
MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, ConstantImm64:$imm, brtarget:$offset),
!strconcat(instr_asm, "\t$rs, $imm, $offset")>;
diff --git a/llvm/test/MC/Mips/macro-bcc-imm-delay-slot.s b/llvm/test/MC/Mips/macro-bcc-imm-delay-slot.s
new file mode 100644
index 0000000000000..780e5053fc198
--- /dev/null
+++ b/llvm/test/MC/Mips/macro-bcc-imm-delay-slot.s
@@ -0,0 +1,33 @@
+# RUN: llvm-mc %s -triple=mipsel -mcpu=mips32r2 -filetype=obj -o - | \
+# RUN: llvm-objdump -d -z - | FileCheck %s
+
+.text
+.set reorder
+reorder:
+ blt $9, -1022, target
+ bne $25, $zero, target
+ nop
+
+.set noreorder
+noreorder:
+ blt $9, -1022, target
+ bne $25, $zero, target
+ nop
+
+target:
+ nop
+
+# CHECK-LABEL: <reorder>:
+# CHECK-NEXT: addiu $1, $zero, -0x3fe
+# CHECK-NEXT: slt $1, $9, $1
+# CHECK-NEXT: bnez $1,
+# CHECK-NEXT: nop
+# CHECK-NEXT: bnez $25,
+# CHECK-NEXT: nop
+
+# CHECK-LABEL: <noreorder>:
+# CHECK-NEXT: addiu $1, $zero, -0x3fe
+# CHECK-NEXT: slt $1, $9, $1
+# CHECK-NEXT: bnez $1,
+# CHECK-NEXT: bnez $25,
+# CHECK-NEXT: nop
More information about the llvm-commits
mailing list