[llvm] MIPS: readsWritesFloatRegister, inc Idx for continue (PR #179932)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 5 04:18:37 PST 2026
https://github.com/wzssyqa created https://github.com/llvm/llvm-project/pull/179932
Otherwise, the input register will also be treat as write.
>From 4405e9ad4c00bced7a605e6ea5f4ce8f2e8d2019 Mon Sep 17 00:00:00 2001
From: YunQiang Su <yunqiang at isrc.iscas.ac.cn>
Date: Thu, 5 Feb 2026 20:17:03 +0800
Subject: [PATCH] MIPS: readsWritesFloatRegister, inc Idx for continue
Otherwise, the input register will also be treat as write.
---
llvm/lib/Target/Mips/MipsSEInstrInfo.cpp | 4 ++--
.../mips32r6-copyPhysReg-fcmp-f64-to-gpr.mir | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
create mode 100644 llvm/test/CodeGen/MIR/Mips/mips32r6-copyPhysReg-fcmp-f64-to-gpr.mir
diff --git a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp
index 39ae73c704ca7..4fbf54c72060d 100644
--- a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp
+++ b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp
@@ -77,10 +77,11 @@ static std::pair<bool, bool> readsWritesFloatRegister(MachineInstr &MI,
Register Reg) {
bool Reads = false;
bool Writes = false;
- unsigned Idx = 0;
+ int Idx = -1;
Register RegF32 = getFloatRegFromFReg(Reg);
assert(RegF32 != Mips::NoRegister && "Reg is not a Float Register");
for (llvm::MachineOperand &MO : MI.operands()) {
+ Idx++;
if (!MO.isReg())
continue;
Register MORegF32 = getFloatRegFromFReg(MO.getReg());
@@ -92,7 +93,6 @@ static std::pair<bool, bool> readsWritesFloatRegister(MachineInstr &MI,
else
Reads = true;
}
- Idx++;
}
return std::make_pair(Reads, Writes);
}
diff --git a/llvm/test/CodeGen/MIR/Mips/mips32r6-copyPhysReg-fcmp-f64-to-gpr.mir b/llvm/test/CodeGen/MIR/Mips/mips32r6-copyPhysReg-fcmp-f64-to-gpr.mir
new file mode 100644
index 0000000000000..ba98a525c24b5
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/Mips/mips32r6-copyPhysReg-fcmp-f64-to-gpr.mir
@@ -0,0 +1,18 @@
+# RUN: llc -mtriple=mipsisa32r6-linux-gnu -verify-machineinstrs %s -o - | FileCheck %s
+
+name: f
+alignment: 4
+tracksRegLiveness: true
+body: |
+ bb.0.entry:
+ liveins: $d12_64, $d14_64
+
+ renamable $d0_64 = CMP_LT_D renamable $d14_64, renamable $d12_64
+ ; CHECK: cmp.lt.d
+ $v1 = MFC1_D64 $d0_64
+ ; CHECK: mfc1
+ renamable $v0 = COPY renamable $d0_64
+ ; CHECK: mfc1
+ renamable $v0 = SUBu killed renamable $v1, killed renamable $v0
+ RetRA implicit $v0
+...
More information about the llvm-commits
mailing list