[llvm] Remove dead flags from virtual registers, but only when not compiling for MIPS (PR #86462)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 24 19:17:27 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: AtariDreams (AtariDreams)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/lib/CodeGen/LiveVariables.cpp (+4-1) 


``````````diff
diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index b85526cfb380b6..9395026915fd90 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/Passes.h"
@@ -494,6 +495,7 @@ void LiveVariables::runOnInstr(MachineInstr &MI,
   SmallVector<unsigned, 4> UseRegs;
   SmallVector<unsigned, 4> DefRegs;
   SmallVector<unsigned, 1> RegMasks;
+  Triple::ArchType TargetArch = *MF->getTarget().getTargetTriple().getArch();
   for (unsigned i = 0; i != NumOperandsToProcess; ++i) {
     MachineOperand &MO = MI.getOperand(i);
     if (MO.isRegMask()) {
@@ -512,7 +514,8 @@ void LiveVariables::runOnInstr(MachineInstr &MI,
       assert(MO.isDef());
       // FIXME: We should not remove any dead flags. However the MIPS RDDSP
       // instruction needs it at the moment: http://llvm.org/PR27116.
-      if (MOReg.isPhysical() && !MRI->isReserved(MOReg))
+      if (!MRI->isReserved(MOReg) &&
+          (Triple::getArchTypePrefix(Arch) != "mips" || !MOReg.isPhysical()))
         MO.setIsDead(false);
       DefRegs.push_back(MOReg);
     }

``````````

</details>


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


More information about the llvm-commits mailing list