[PATCH] D100023: [PowerPC] fixup killed flags for ri + addi to ri transformation

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 7 19:04:54 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG74e77295e754: [PowerPC] fixup killed flags for ri + addi to ri transformation (authored by shchenz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100023/new/

https://reviews.llvm.org/D100023

Files:
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir


Index: llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir
===================================================================
--- llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir
+++ llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir
@@ -65,3 +65,35 @@
   $x3 = COPY %5:g8rc
   BLR8 implicit $lr8, implicit $rm, implicit $x3
 ...
+---
+name: killFlagSameBlock
+#CHECK : name : killFlagSameBlock
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+  liveins: $x3
+    %0:g8rc_and_g8rc_nox0 = COPY $x3
+    %1:g8rc_and_g8rc_nox0 = ADDI8 killed %0:g8rc_and_g8rc_nox0, -8
+    ; CHECK: %1:g8rc_and_g8rc_nox0 = ADDI8 %0, -8
+    %2:g8rc = LI8 0
+    ; CHECK: STD killed %2, 8, killed %0
+    STD killed %2:g8rc, 16, %1:g8rc_and_g8rc_nox0
+    BLR8 implicit $lr8, implicit $rm
+...
+---
+name: killFlagDifferentBlocks
+#CHECK : name : killFlagDifferentBlocks
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+  liveins: $x3
+    %0:g8rc_and_g8rc_nox0 = COPY $x3
+    ; CHECK: %1:g8rc_and_g8rc_nox0 = ADDI8 %0, -8
+    %1:g8rc_and_g8rc_nox0 = ADDI8 killed %0:g8rc_and_g8rc_nox0, -8
+
+  bb.1:
+    %2:g8rc = LI8 0
+    ; CHECK: STD killed %2, 8, killed %0
+    STD killed %2:g8rc, 16, %1:g8rc_and_g8rc_nox0
+    BLR8 implicit $lr8, implicit $rm
+...
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -4744,7 +4744,12 @@
   LLVM_DEBUG(DefMI.dump());
 
   MI.getOperand(III.OpNoForForwarding).setReg(RegMO->getReg());
-  MI.getOperand(III.OpNoForForwarding).setIsKill(RegMO->isKill());
+  if (RegMO->isKill()) {
+    MI.getOperand(III.OpNoForForwarding).setIsKill(true);
+    // Clear the killed flag in RegMO. Doing this here can handle some cases
+    // that DefMI and MI are not in same basic block.
+    RegMO->setIsKill(false);
+  }
   MI.getOperand(III.ImmOpNo).setImm(Imm);
 
   // FIXME: fix kill/dead flag if MI and DefMI are not in same basic block.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100023.335973.patch
Type: text/x-patch
Size: 2014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/5cbdf973/attachment.bin>


More information about the llvm-commits mailing list