[llvm] [LiveVariables] Mark use as implicit-def if def is a subregister (PR #119446)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 12:43:07 PST 2024


================
@@ -277,10 +277,21 @@ void LiveVariables::HandlePhysRegUse(Register Reg, MachineInstr &MI) {
           continue;
         if (PartDefRegs.count(SubReg))
           continue;
+
+        // Check if SubReg is defined at LastPartialDef.
+        bool IsDefinedHere = false;
+        for (int i = 0; i < LastPartialDef->getNumOperands(); ++i) {
+          auto MO = LastPartialDef->getOperand(i);
+          if (!MO.isDef()) continue;
+          if (TRI->isSubRegister(SubReg, MO.getReg())) {
+            IsDefinedHere = true;
+            break;
+          }
+        }
         // This part of Reg was defined before the last partial def. It's killed
         // here.
         LastPartialDef->addOperand(MachineOperand::CreateReg(SubReg,
-                                                             false/*IsDef*/,
+                                                             IsDefinedHere/*IsDef*/,
----------------
shiltian wrote:

```suggestion
                                                             IsDefinedHere,
```

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


More information about the llvm-commits mailing list